13 * to license@zend.com so we can send you a copy immediately. |
13 * to license@zend.com so we can send you a copy immediately. |
14 * |
14 * |
15 * @category Zend |
15 * @category Zend |
16 * @package Zend_Tool |
16 * @package Zend_Tool |
17 * @subpackage Framework |
17 * @subpackage Framework |
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
18 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
19 * @license http://framework.zend.com/license/new-bsd New BSD License |
20 * @version $Id: Console.php 23204 2010-10-21 15:35:21Z ralph $ |
20 * @version $Id: Console.php 24593 2012-01-05 20:35:02Z matthew $ |
21 */ |
21 */ |
22 |
22 |
23 /** |
23 /** |
24 * @see Zend_Tool_Framework_Client_Abstract |
24 * @see Zend_Tool_Framework_Client_Abstract |
25 */ |
25 */ |
38 /** |
38 /** |
39 * Zend_Tool_Framework_Client_Console - the CLI Client implementation for Zend_Tool_Framework |
39 * Zend_Tool_Framework_Client_Console - the CLI Client implementation for Zend_Tool_Framework |
40 * |
40 * |
41 * @category Zend |
41 * @category Zend |
42 * @package Zend_Tool |
42 * @package Zend_Tool |
43 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
43 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
44 * @license http://framework.zend.com/license/new-bsd New BSD License |
44 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
45 * |
|
46 * @todo methods need more API documentation. |
45 */ |
47 */ |
46 class Zend_Tool_Framework_Client_Console |
48 class Zend_Tool_Framework_Client_Console |
47 extends Zend_Tool_Framework_Client_Abstract |
49 extends Zend_Tool_Framework_Client_Abstract |
48 implements Zend_Tool_Framework_Client_Interactive_InputInterface, |
50 implements Zend_Tool_Framework_Client_Interactive_InputInterface, |
49 Zend_Tool_Framework_Client_Interactive_OutputInterface |
51 Zend_Tool_Framework_Client_Interactive_OutputInterface |
92 */ |
94 */ |
93 public function getName() |
95 public function getName() |
94 { |
96 { |
95 return 'console'; |
97 return 'console'; |
96 } |
98 } |
97 |
99 |
98 /** |
100 /** |
99 * setConfigOptions() |
101 * setConfigOptions() |
100 * |
102 * |
101 * @param $configOptions |
103 * @param array $configOptions |
102 */ |
104 */ |
103 public function setConfigOptions($configOptions) |
105 public function setConfigOptions($configOptions) |
104 { |
106 { |
105 $this->_configOptions = $configOptions; |
107 $this->_configOptions = $configOptions; |
106 return $this; |
108 return $this; |
107 } |
109 } |
108 |
110 |
109 /** |
111 /** |
110 * setStorageOptions() |
112 * setStorageOptions() |
111 * |
113 * |
112 * @param $storageOptions |
114 * @param array $storageOptions |
113 */ |
115 */ |
114 public function setStorageOptions($storageOptions) |
116 public function setStorageOptions($storageOptions) |
115 { |
117 { |
116 $this->_storageOptions = $storageOptions; |
118 $this->_storageOptions = $storageOptions; |
117 return $this; |
119 return $this; |
118 } |
120 } |
119 |
121 |
|
122 /** |
|
123 * @param array $classesToLoad |
|
124 */ |
120 public function setClassesToLoad($classesToLoad) |
125 public function setClassesToLoad($classesToLoad) |
121 { |
126 { |
122 $this->_classesToLoad = $classesToLoad; |
127 $this->_classesToLoad = $classesToLoad; |
123 return $this; |
128 return $this; |
124 } |
129 } |
143 ); |
148 ); |
144 } |
149 } |
145 |
150 |
146 // which classes are essential to initializing Zend_Tool_Framework_Client_Console |
151 // which classes are essential to initializing Zend_Tool_Framework_Client_Console |
147 $classesToLoad = array( |
152 $classesToLoad = array( |
148 'Zend_Tool_Framework_Client_Console_Manifest', |
153 'Zend_Tool_Framework_Client_Console_Manifest', |
149 'Zend_Tool_Framework_System_Manifest' |
154 'Zend_Tool_Framework_System_Manifest' |
150 ); |
155 ); |
151 |
156 |
152 if ($this->_classesToLoad) { |
157 if ($this->_classesToLoad) { |
153 if (is_string($this->_classesToLoad)) { |
158 if (is_string($this->_classesToLoad)) { |
154 $classesToLoad[] = $this->_classesToLoad; |
159 $classesToLoad[] = $this->_classesToLoad; |
155 } elseif (is_array($this->_classesToLoad)) { |
160 } elseif (is_array($this->_classesToLoad)) { |
156 $classesToLoad = array_merge($classesToLoad, $this->_classesToLoad); |
161 $classesToLoad = array_merge($classesToLoad, $this->_classesToLoad); |
157 } |
162 } |
158 } |
163 } |
159 |
164 |
160 // add classes to the basic loader from the config file basicloader.classes.1 .. |
165 // add classes to the basic loader from the config file basicloader.classes.1 .. |
161 if (isset($config->basicloader) && isset($config->basicloader->classes)) { |
166 if (isset($config->basicloader) && isset($config->basicloader->classes)) { |
162 foreach ($config->basicloader->classes as $classKey => $className) { |
167 foreach ($config->basicloader->classes as $classKey => $className) { |
163 array_push($classesToLoad, $className); |
168 array_push($classesToLoad, $className); |
164 } |
169 } |
184 $response->addContentDecorator(new Zend_Tool_Framework_Client_Console_ResponseDecorator_Blockize()); |
189 $response->addContentDecorator(new Zend_Tool_Framework_Client_Console_ResponseDecorator_Blockize()); |
185 |
190 |
186 if (function_exists('posix_isatty')) { |
191 if (function_exists('posix_isatty')) { |
187 $response->addContentDecorator(new Zend_Tool_Framework_Client_Console_ResponseDecorator_Colorizer()); |
192 $response->addContentDecorator(new Zend_Tool_Framework_Client_Console_ResponseDecorator_Colorizer()); |
188 } |
193 } |
189 |
194 |
190 $response->addContentDecorator(new Zend_Tool_Framework_Client_Response_ContentDecorator_Separator()) |
195 $response->addContentDecorator(new Zend_Tool_Framework_Client_Response_ContentDecorator_Separator()) |
191 ->setDefaultDecoratorOptions(array('separator' => true)); |
196 ->setDefaultDecoratorOptions(array('separator' => true)); |
192 |
197 |
193 $optParser = new Zend_Tool_Framework_Client_Console_ArgumentParser(); |
198 $optParser = new Zend_Tool_Framework_Client_Console_ArgumentParser(); |
194 $optParser->setArguments($_SERVER['argv']) |
199 $optParser->setArguments($_SERVER['argv']) |