mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #6938 from robbieaverill/pulls/4.0/remove-create-function
Remove createMethod and create_function implementations, replace with closures
This commit is contained in:
commit
2284121a91
@ -1295,6 +1295,7 @@ After (`mysite/_config/config.yml`):
|
||||
* `Injector` now complies with [PSR-11](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-11-container.md).
|
||||
Accordingly, `hasService()` has been renamed to `has()`, and `get()` will throw
|
||||
`SilverStripe\Core\Injector\InjectorNotFoundException` when the service can't be found.
|
||||
* Removed `CustomMethods::createMethod()`. Use closures instead.
|
||||
|
||||
#### <a name="overview-general-deprecated"></a>General and Core Deprecated API
|
||||
|
||||
|
@ -292,20 +292,4 @@ trait CustomMethods
|
||||
'method' => $method
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an extra method using raw PHP code passed as a string
|
||||
*
|
||||
* @param string $method the method name
|
||||
* @param string $code the PHP code - arguments will be in an array called $args, while you can access this object
|
||||
* by using $obj. Note that you cannot call protected methods, as the method is actually an external
|
||||
* function
|
||||
*/
|
||||
protected function createMethod($method, $code)
|
||||
{
|
||||
$class = get_class($this);
|
||||
self::$extra_methods[$class][strtolower($method)] = array (
|
||||
'function' => create_function('$obj, $args', $code)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1389,7 +1389,9 @@ class Installer extends InstallRequirements {
|
||||
$locale = isset($_POST['locale']) ? addcslashes($_POST['locale'], "\'") : 'en_US';
|
||||
$type = addcslashes($config['db']['type'], "\'");
|
||||
$dbConfig = $config['db'][$type];
|
||||
$dbConfig = array_map(create_function('$v', 'return addcslashes($v, "\\\'");'), $dbConfig);
|
||||
foreach ($dbConfig as &$configValue) {
|
||||
$configValue = addcslashes($configValue, "\\\'");
|
||||
}
|
||||
if(!isset($dbConfig['path'])) $dbConfig['path'] = '';
|
||||
if(!$dbConfig) {
|
||||
echo "<p style=\"color: red\">Bad config submitted</p><pre>";
|
||||
|
@ -826,7 +826,9 @@ class Form extends ViewableData implements HasRequestHandler
|
||||
$attrs = $this->getAttributes();
|
||||
|
||||
// Remove empty
|
||||
$attrs = array_filter((array)$attrs, create_function('$v', 'return ($v || $v === 0);'));
|
||||
$attrs = array_filter((array)$attrs, function ($value) {
|
||||
return ($value || $value === 0);
|
||||
});
|
||||
|
||||
// Remove excluded
|
||||
if ($exclude) {
|
||||
|
@ -25,8 +25,6 @@ class T2 extends Object
|
||||
$this->addMethodsFrom('failover');
|
||||
$this->addMethodsFrom('failoverArr', 0);
|
||||
$this->addMethodsFrom('failoverArr', 1);
|
||||
|
||||
$this->createMethod('testCreateMethod', 'return "created";');
|
||||
}
|
||||
|
||||
public function wrappedMethod($val)
|
||||
|
Loading…
Reference in New Issue
Block a user