Skip to content

Commit

Permalink
Removing ShellDispatcher as a constructor argument for Shell.
Browse files Browse the repository at this point in the history
Updating the AclShell test case.
  • Loading branch information
markstory committed Oct 24, 2010
1 parent 0b2a6ac commit ba17e2c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 23 deletions.
9 changes: 4 additions & 5 deletions cake/console/libs/task_collection.php
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion cake/console/shell_dispatcher.php
Expand Up @@ -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;
}

Expand Down
14 changes: 2 additions & 12 deletions cake/console/shells/shell.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 1 addition & 5 deletions cake/tests/cases/console/shells/acl.test.php
Expand Up @@ -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);
Expand Down

0 comments on commit ba17e2c

Please sign in to comment.