1: <?php
2: /**
3: * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4: * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
5: *
6: * Licensed under The MIT License
7: * For full copyright and license information, please see the LICENSE.txt
8: * Redistributions of files must retain the above copyright notice
9: *
10: * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11: * @since 3.5.0
12: * @license http://www.opensource.org/licenses/mit-license.php MIT License
13: */
14: namespace Cake\TestSuite;
15:
16: use Cake\Console\ShellDispatcher;
17:
18: /**
19: * Allows injecting mock IO into shells
20: */
21: class LegacyShellDispatcher extends ShellDispatcher
22: {
23: /**
24: * @var \Cake\Console\ConsoleIo
25: */
26: protected $_io;
27:
28: /**
29: * Constructor
30: *
31: * @param array $args Argument array
32: * @param bool $bootstrap Initialize environment
33: * @param \Cake\Console\ConsoleIo $io ConsoleIo
34: */
35: public function __construct($args = [], $bootstrap = true, $io = null)
36: {
37: $this->_io = $io;
38: parent::__construct($args, $bootstrap);
39: }
40:
41: /**
42: * Injects mock and stub io components into the shell
43: *
44: * @param string $className Class name
45: * @param string $shortName Short name
46: * @return \Cake\Console\Shell
47: */
48: protected function _createShell($className, $shortName)
49: {
50: list($plugin) = pluginSplit($shortName);
51: $instance = new $className($this->_io);
52: $instance->plugin = trim($plugin, '.');
53:
54: return $instance;
55: }
56: }
57: