Remove create_function implementations, replace with closures

This commit is contained in:
Robbie Averill 2017-05-19 15:57:53 +12:00
parent 8953c09e9a
commit b394718b42
3 changed files with 10 additions and 8 deletions

View File

@ -1984,7 +1984,9 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
// This filter ensures that the ParentID dropdown selection does not show this node, // This filter ensures that the ParentID dropdown selection does not show this node,
// or its descendents, as this causes vanishing bugs // or its descendents, as this causes vanishing bugs
$parentIDField->setFilterFunction(create_function('$node', "return \$node->ID != {$this->ID};")); $parentIDField->setFilterFunction(function ($node) {
return $node->ID != $this->ID;
});
$parentTypeSelector->addExtraClass('parentTypeSelector'); $parentTypeSelector->addExtraClass('parentTypeSelector');
$tabBehaviour->setTitle(_t(__CLASS__.'.TABBEHAVIOUR', "Behavior")); $tabBehaviour->setTitle(_t(__CLASS__.'.TABBEHAVIOUR', "Behavior"));

View File

@ -210,7 +210,7 @@ class VirtualPage extends Page
"SilverStripe\\CMS\\Model\\SiteTree" "SilverStripe\\CMS\\Model\\SiteTree"
); );
// filter doesn't let you select children of virtual pages as as source page // filter doesn't let you select children of virtual pages as as source page
//$copyContentFromField->setFilterFunction(create_function('$item', 'return !($item instanceof VirtualPage);')); //$copyContentFromField->setFilterFunction(function ($item) { return !($item instanceof VirtualPage); });
// Setup virtual fields // Setup virtual fields
if ($virtualFields = $this->getVirtualFields()) { if ($virtualFields = $this->getVirtualFields()) {

View File

@ -148,12 +148,12 @@ class SearchForm extends Form
$keywords = $request->requestVar('Search'); $keywords = $request->requestVar('Search');
$andProcessor = create_function('$matches', ' $andProcessor = function ($matches) {
return " +" . $matches[2] . " +" . $matches[4] . " "; return ' +' . $matches[2] . ' +' . $matches[4] . ' ';
'); };
$notProcessor = create_function('$matches', ' $notProcessor = function ($matches) {
return " -" . $matches[3]; return ' -' . $matches[3];
'); };
$keywords = preg_replace_callback('/()("[^()"]+")( and )("[^"()]+")()/i', $andProcessor, $keywords); $keywords = preg_replace_callback('/()("[^()"]+")( and )("[^"()]+")()/i', $andProcessor, $keywords);
$keywords = preg_replace_callback('/(^| )([^() ]+)( and )([^ ()]+)( |$)/i', $andProcessor, $keywords); $keywords = preg_replace_callback('/(^| )([^() ]+)( and )([^ ()]+)( |$)/i', $andProcessor, $keywords);