From e51455cb17ab6c644a668b8b982c0f3f1d9d89ff Mon Sep 17 00:00:00 2001 From: gwoo Date: Fri, 9 Nov 2007 19:56:40 +0000 Subject: [PATCH] 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 --- cake/libs/controller/controller.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/cake/libs/controller/controller.php b/cake/libs/controller/controller.php index c8402713b..5ddde55b0 100644 --- a/cake/libs/controller/controller.php +++ b/cake/libs/controller/controller.php @@ -297,18 +297,15 @@ class Controller extends Object { $this->modelClass = Inflector::classify($this->name); $this->modelKey = Inflector::underscore($this->modelClass); - - if (is_subclass_of($this, 'AppController')) { + if (is_subclass_of($this, 'AppController') || is_subclass_of($this, Inflector::camelize($this->plugin) . '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})); @@ -336,6 +333,26 @@ class Controller extends Object { * @see Controller::loadModel() */ 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())) { return false; }