Skip to content

Commit

Permalink
Making HelperRegistry accept a ConsoleIO in a setter
Browse files Browse the repository at this point in the history
Passing it in the contructor was problematic as both classes depend
on each other.
  • Loading branch information
lorenzo committed Jun 17, 2015
1 parent 655dafd commit 6ebd6e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/Console/ConsoleIo.php
Expand Up @@ -107,7 +107,8 @@ public function __construct(ConsoleOutput $out = null, ConsoleOutput $err = null
$this->_out = $out ? $out : new ConsoleOutput('php://stdout');
$this->_err = $err ? $err : new ConsoleOutput('php://stderr');
$this->_in = $in ? $in : new ConsoleInput('php://stdin');
$this->_helpers = $helpers ? $helpers : new HelperRegistry($this);
$this->_helpers = $helpers ? $helpers : new HelperRegistry();
$this->_helpers->setIo($this);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Console/HelperRegistry.php
Expand Up @@ -34,11 +34,11 @@ class HelperRegistry extends ObjectRegistry
protected $_io;

/**
* Constructor
* Sets The IO instance that should be passed to the shell helpers
*
* @param \Cake\Console\ConsoleIo $io An io instance.
*/
public function __construct(ConsoleIo $io)
public function setIo(ConsoleIo $io)
{
$this->_io = $io;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/TestCase/Console/HelperRegistryTest.php
Expand Up @@ -35,7 +35,8 @@ public function setUp()
parent::setUp();
Configure::write('App.namespace', 'TestApp');
$io = $this->getMock('Cake\Console\ConsoleIo', [], [], '', false);
$this->helpers = new HelperRegistry($io);
$this->helpers = new HelperRegistry();
$this->helpers->setIo($io);
}

/**
Expand Down

0 comments on commit 6ebd6e1

Please sign in to comment.