Skip to content

Commit

Permalink
Starting to switch to a _mergeParent. This will allow un skipping of …
Browse files Browse the repository at this point in the history
…many tests, and make mergeVars more flexible.
  • Loading branch information
markstory committed Dec 16, 2010
1 parent 862a2bc commit 6206fef
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cake/libs/controller/controller.php
Expand Up @@ -272,6 +272,15 @@ class Controller extends Object {
*/
public $validationErrors = null;

/**
* The class name of the parent class you wish to merge with.
* Typically this is AppController, but you may wish to merge vars with a different
* parent class.
*
* @var string
*/
protected $_mergeParent = 'AppController';

/**
* Constructor.
*
Expand Down Expand Up @@ -394,7 +403,7 @@ public function setRequest(CakeRequest $request) {
}

/**
* Merge components, helpers, and uses vars from AppController and PluginAppController.
* Merge components, helpers, and uses vars from Controller::$_mergeParent and PluginAppController.
*
* @return void
*/
Expand All @@ -410,8 +419,8 @@ protected function __mergeVars() {
$plugin = $pluginName . '.';
}

if (is_subclass_of($this, 'AppController') || !empty($pluginController)) {
$appVars = get_class_vars('AppController');
if (is_subclass_of($this, $this->_mergeParent) || !empty($pluginController)) {
$appVars = get_class_vars($this->_mergeParent);
$uses = $appVars['uses'];
$merge = array('components', 'helpers');

Expand All @@ -430,7 +439,7 @@ protected function __mergeVars() {
) {
$this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses));
}
$this->_mergeVars($merge, 'AppController', true);
$this->_mergeVars($merge, $this->_mergeParent, true);
}

if ($pluginController && $pluginName != null) {
Expand Down

0 comments on commit 6206fef

Please sign in to comment.