Fixing the Api shell

This commit is contained in:
Jose Lorenzo Rodriguez 2011-03-08 15:37:15 -04:30
parent dac34555f8
commit 4c90868652

View file

@ -41,13 +41,13 @@ class ApiShell extends Shell {
*/ */
public function initialize() { public function initialize() {
$this->paths = array_merge($this->paths, array( $this->paths = array_merge($this->paths, array(
'behavior' => LIBS . 'model' . DS . 'behaviors' . DS, 'behavior' => LIBS . 'Model' . DS . 'Behavior' . DS,
'cache' => LIBS . 'cache' . DS, 'cache' => LIBS . 'Cache' . DS,
'controller' => LIBS . 'controller' . DS, 'controller' => LIBS . 'Controller' . DS,
'component' => LIBS . 'controller' . DS . 'components' . DS, 'component' => LIBS . 'Controller' . DS . 'Component' . DS,
'helper' => LIBS . 'view' . DS . 'helpers' . DS, 'helper' => LIBS . 'View' . DS . 'Helper' . DS,
'model' => LIBS . 'model' . DS, 'model' => LIBS . 'Model' . DS,
'view' => LIBS . 'view' . DS, 'view' => LIBS . 'View' . DS,
'core' => LIBS 'core' => LIBS
)); ));
} }
@ -74,7 +74,7 @@ class ApiShell extends Shell {
$class = Inflector::camelize($type); $class = Inflector::camelize($type);
} elseif (count($this->args) > 1) { } elseif (count($this->args) > 1) {
$file = Inflector::underscore($this->args[1]); $file = Inflector::underscore($this->args[1]);
$class = Inflector::camelize($file); $class = Inflector::camelize($this->args[1]);
} }
$objects = App::objects('class', $path); $objects = App::objects('class', $path);
if (in_array($class, $objects)) { if (in_array($class, $objects)) {
@ -88,7 +88,7 @@ class ApiShell extends Shell {
$this->error(__('%s not found', $class)); $this->error(__('%s not found', $class));
} }
$parsed = $this->__parseClass($path . $file .'.php', $class); $parsed = $this->__parseClass($path . $class .'.php', $class);
if (!empty($parsed)) { if (!empty($parsed)) {
if (isset($this->params['method'])) { if (isset($this->params['method'])) {
@ -197,9 +197,12 @@ class ApiShell extends Shell {
function __parseClass($path, $class) { function __parseClass($path, $class) {
$parsed = array(); $parsed = array();
if (!class_exists($class)) {
if (!include_once($path)) { if (!include_once($path)) {
$this->err(__('%s could not be found', $path)); $this->err(__('%s could not be found', $path));
} }
}
$reflection = new ReflectionClass($class); $reflection = new ReflectionClass($class);
foreach ($reflection->getMethods() as $method) { foreach ($reflection->getMethods() as $method) {