mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Moving _mergeVars() into Object as its common to Controller, Model and Shell.
This commit is contained in:
parent
8f82156a51
commit
8821bec049
4 changed files with 28 additions and 69 deletions
|
@ -176,26 +176,6 @@ class Shell extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Merges this objects $property with the property in $class' definition.
|
|
||||||
* This classes value for the property will be merged on top of $class'
|
|
||||||
*
|
|
||||||
* This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine
|
|
||||||
* this method as an empty function.
|
|
||||||
*
|
|
||||||
* @param array $properties The name of the properties to merge.
|
|
||||||
* @param sting $class The class to merge the property with.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function _mergeVars($properties, $class) {
|
|
||||||
$classProperties = get_class_vars($class);
|
|
||||||
foreach ($properties as $var) {
|
|
||||||
if (isset($classProperties[$var]) && !empty($classProperties[$var]) && is_array($this->{$var})) {
|
|
||||||
$this->{$var} = Set::merge($classProperties[$var], $this->{$var});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the Shell
|
* Initializes the Shell
|
||||||
* acts as constructor for subclasses
|
* acts as constructor for subclasses
|
||||||
|
|
|
@ -409,38 +409,13 @@ class Controller extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Merges this objects $property with the property in $class' definition.
|
|
||||||
* This classes value for the property will be merged on top of $class'
|
|
||||||
*
|
|
||||||
* This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine
|
|
||||||
* this method as an empty function.
|
|
||||||
*
|
|
||||||
* @param array $properties The name of the properties to merge.
|
|
||||||
* @param sting $class The class to merge the property with.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function _mergeVars($properties, $class) {
|
|
||||||
$classProperties = get_class_vars($class);
|
|
||||||
foreach ($properties as $var) {
|
|
||||||
if (
|
|
||||||
isset($classProperties[$var]) &&
|
|
||||||
!empty($classProperties[$var]) &&
|
|
||||||
is_array($this->{$var}) &&
|
|
||||||
$this->{$var} != $classProperties[$var]
|
|
||||||
) {
|
|
||||||
$this->{$var} = Set::merge($classProperties[$var], $this->{$var});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge components, helpers, and uses vars from AppController and PluginAppController.
|
* Merge components, helpers, and uses vars from AppController and PluginAppController.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function __mergeVars() {
|
protected function __mergeVars() {
|
||||||
$pluginName = $pluginController = null;
|
$pluginName = $pluginController = $plugin = null;
|
||||||
|
|
||||||
if (!empty($this->plugin)) {
|
if (!empty($this->plugin)) {
|
||||||
$pluginName = Inflector::camelize($this->plugin);
|
$pluginName = Inflector::camelize($this->plugin);
|
||||||
|
@ -472,7 +447,7 @@ class Controller extends Object {
|
||||||
$this->_mergeVars($merge, 'AppController');
|
$this->_mergeVars($merge, 'AppController');
|
||||||
foreach ($merge as $prop) {
|
foreach ($merge as $prop) {
|
||||||
if ($prop !== 'components') {
|
if ($prop !== 'components') {
|
||||||
$this->{$prop} = array_unique($this->{$prop});
|
$this->{$prop} = array_unique((array)$this->{$prop});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,7 +463,7 @@ class Controller extends Object {
|
||||||
$this->_mergeVars($merge, $pluginController);
|
$this->_mergeVars($merge, $pluginController);
|
||||||
foreach ($merge as $prop) {
|
foreach ($merge as $prop) {
|
||||||
if ($prop !== 'components') {
|
if ($prop !== 'components') {
|
||||||
$this->{$prop} = array_unique($this->{$prop});
|
$this->{$prop} = array_unique((array)$this->{$prop});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -468,27 +468,6 @@ class Model extends Object {
|
||||||
$this->Behaviors->init($this->alias, $this->actsAs);
|
$this->Behaviors->init($this->alias, $this->actsAs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Merges this objects $property with the property in $class' definition.
|
|
||||||
* This classes value for the property will be merged on top of $class'
|
|
||||||
*
|
|
||||||
* This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine
|
|
||||||
* this method as an empty function.
|
|
||||||
*
|
|
||||||
* @param array $properties The name of the properties to merge.
|
|
||||||
* @param sting $class The class to merge the property with.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
protected function _mergeVars($properties, $class) {
|
|
||||||
$classProperties = get_class_vars($class);
|
|
||||||
foreach ($properties as $var) {
|
|
||||||
if (isset($classProperties[$var]) && !empty($classProperties[$var]) && is_array($this->{$var})) {
|
|
||||||
$this->{$var} = Set::merge($classProperties[$var], $this->{$var});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles custom method calls, like findBy<field> for DB models,
|
* Handles custom method calls, like findBy<field> for DB models,
|
||||||
* and custom RPC calls for remote data sources.
|
* and custom RPC calls for remote data sources.
|
||||||
|
|
|
@ -198,6 +198,31 @@ class Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges this objects $property with the property in $class' definition.
|
||||||
|
* This classes value for the property will be merged on top of $class'
|
||||||
|
*
|
||||||
|
* This provides some of the DRY magic CakePHP provides. If you want to shut it off, redefine
|
||||||
|
* this method as an empty function.
|
||||||
|
*
|
||||||
|
* @param array $properties The name of the properties to merge.
|
||||||
|
* @param sting $class The class to merge the property with.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function _mergeVars($properties, $class) {
|
||||||
|
$classProperties = get_class_vars($class);
|
||||||
|
foreach ($properties as $var) {
|
||||||
|
if (
|
||||||
|
isset($classProperties[$var]) &&
|
||||||
|
!empty($classProperties[$var]) &&
|
||||||
|
is_array($this->{$var}) &&
|
||||||
|
$this->{$var} != $classProperties[$var]
|
||||||
|
) {
|
||||||
|
$this->{$var} = Set::merge($classProperties[$var], $this->{$var});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You should choose a unique name for the persistent file
|
* You should choose a unique name for the persistent file
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue