From ba17e2c9a0ebdb0e686b84b9f6b8468646637182 Mon Sep 17 00:00:00 2001 From: mark_story Date: Sun, 24 Oct 2010 14:55:16 -0400 Subject: [PATCH] Removing ShellDispatcher as a constructor argument for Shell. Updating the AclShell test case. --- cake/console/libs/task_collection.php | 9 ++++----- cake/console/shell_dispatcher.php | 2 +- cake/console/shells/shell.php | 14 ++------------ cake/tests/cases/console/shells/acl.test.php | 6 +----- 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/cake/console/libs/task_collection.php b/cake/console/libs/task_collection.php index 40ed967d54e..d28b13b6db7 100644 --- a/cake/console/libs/task_collection.php +++ b/cake/console/libs/task_collection.php @@ -20,12 +20,11 @@ class TaskCollection extends ObjectCollection { /** - * Shell to give to tasks. and use to find tasks. + * Shell to use to set params to tasks. * * @var array */ protected $_Shell; - protected $_Dispatch; /** * The directory inside each shell path that contains tasks. @@ -40,10 +39,10 @@ class TaskCollection extends ObjectCollection { * @param array $paths Array of paths to search for tasks on . * @return void */ - public function __construct(Shell $Shell, ShellDispatcher $dispatcher) { + public function __construct(Shell $Shell) { $this->_Shell = $Shell; - $this->_Dispatch = $dispatcher; } + /** * Loads/constructs a task. Will return the instance in the collection * if it already exists. @@ -72,7 +71,7 @@ public function load($task, $settings = array(), $enable = true) { } $this->_loaded[$name] = new $taskClass( - $this->_Dispatch, $this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin + $this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin ); if ($enable === true) { $this->_enabled[] = $name; diff --git a/cake/console/shell_dispatcher.php b/cake/console/shell_dispatcher.php index ed0ca10a9a0..3a2f9b649a2 100644 --- a/cake/console/shell_dispatcher.php +++ b/cake/console/shell_dispatcher.php @@ -223,7 +223,7 @@ protected function _getShell($shell) { if (!class_exists($class)) { throw new MissingShellClassException(array('shell' => $class)); } - $Shell = new $class($this); + $Shell = new $class(); return $Shell; } diff --git a/cake/console/shells/shell.php b/cake/console/shells/shell.php index 3ec3823fb54..b79d018b46e 100644 --- a/cake/console/shells/shell.php +++ b/cake/console/shells/shell.php @@ -37,14 +37,6 @@ class Shell extends Object { const NORMAL = 1; const QUIET = 0; -/** - * An instance of the ShellDispatcher object that loaded this script - * - * @var ShellDispatcher - * @access public - */ - public $Dispatch = null; - /** * An instance of ConsoleOptionParser that has been configured for this class. * @@ -154,13 +146,11 @@ class Shell extends Object { * Constructs this Shell instance. * */ - function __construct(&$dispatch, $stdout = null, $stderr = null, $stdin = null) { + function __construct($stdout = null, $stderr = null, $stdin = null) { if ($this->name == null) { $this->name = Inflector::underscore(str_replace(array('Shell', 'Task'), '', get_class($this))); } - - $this->Dispatch =& $dispatch; - $this->Tasks = new TaskCollection($this, $dispatch); + $this->Tasks = new TaskCollection($this); $this->stdout = $stdout; $this->stderr = $stderr; diff --git a/cake/tests/cases/console/shells/acl.test.php b/cake/tests/cases/console/shells/acl.test.php index 74807864c86..305ee1ebc09 100644 --- a/cake/tests/cases/console/shells/acl.test.php +++ b/cake/tests/cases/console/shells/acl.test.php @@ -52,14 +52,10 @@ public function setUp() { $out = $this->getMock('ConsoleOutput', array(), array(), '', false); $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Dispatcher = $this->getMock( - 'ShellDispatcher', - array('_stop', '_initEnvironment', 'dispatch') - ); $this->Task = $this->getMock( 'AclShell', array('in', 'out', 'hr', 'createFile', 'error', 'err', 'clear', 'dispatchShell'), - array(&$this->Dispatcher, $out, $out, $in) + array($out, $out, $in) ); $collection = new ComponentCollection(); $this->Task->Acl = new AclComponent($collection);