mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding merge support for PluginAppController properties
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5978 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
597026bc4c
commit
e51455cb17
1 changed files with 21 additions and 4 deletions
|
@ -297,18 +297,15 @@ class Controller extends Object {
|
||||||
|
|
||||||
$this->modelClass = Inflector::classify($this->name);
|
$this->modelClass = Inflector::classify($this->name);
|
||||||
$this->modelKey = Inflector::underscore($this->modelClass);
|
$this->modelKey = Inflector::underscore($this->modelClass);
|
||||||
|
if (is_subclass_of($this, 'AppController') || is_subclass_of($this, Inflector::camelize($this->plugin) . 'AppController')) {
|
||||||
if (is_subclass_of($this, 'AppController')) {
|
|
||||||
$appVars = get_class_vars('AppController');
|
$appVars = get_class_vars('AppController');
|
||||||
$uses = $appVars['uses'];
|
$uses = $appVars['uses'];
|
||||||
$merge = array('components', 'helpers');
|
$merge = array('components', 'helpers');
|
||||||
|
|
||||||
if ($uses == $this->uses && !empty($this->uses)) {
|
if ($uses == $this->uses && !empty($this->uses)) {
|
||||||
array_unshift($this->uses, $this->modelClass);
|
array_unshift($this->uses, $this->modelClass);
|
||||||
} elseif ($this->uses !== null || $this->uses !== false) {
|
} elseif ($this->uses !== null || $this->uses !== false) {
|
||||||
$merge[] = 'uses';
|
$merge[] = 'uses';
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($merge as $var) {
|
foreach ($merge as $var) {
|
||||||
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
|
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
|
||||||
$this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
|
$this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
|
||||||
|
@ -336,6 +333,26 @@ class Controller extends Object {
|
||||||
* @see Controller::loadModel()
|
* @see Controller::loadModel()
|
||||||
*/
|
*/
|
||||||
function constructClasses() {
|
function constructClasses() {
|
||||||
|
if(isset($this->plugin)) {
|
||||||
|
$appController = Inflector::camelize($this->plugin) . 'AppController';
|
||||||
|
if (is_subclass_of($this, $appController)) {
|
||||||
|
$appVars = get_class_vars($appController);
|
||||||
|
$uses = $appVars['uses'];
|
||||||
|
$merge = array('components', 'helpers');
|
||||||
|
if ($uses == $this->uses && !empty($this->uses)) {
|
||||||
|
array_unshift($this->uses, $this->modelClass);
|
||||||
|
} elseif ($this->uses !== null || $this->uses !== false) {
|
||||||
|
$merge[] = 'uses';
|
||||||
|
}
|
||||||
|
foreach ($merge as $var) {
|
||||||
|
if (isset($appVars[$var]) && !empty($appVars[$var]) && is_array($this->{$var})) {
|
||||||
|
$this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->uses === null || ($this->uses === array())) {
|
if ($this->uses === null || ($this->uses === array())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue