Skip to content

Commit

Permalink
Move Console Shells and Tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Aug 25, 2014
1 parent 1951b16 commit 6b02f80
Show file tree
Hide file tree
Showing 56 changed files with 165 additions and 164 deletions.
2 changes: 1 addition & 1 deletion src/Console/ShellDispatcher.php
Expand Up @@ -198,7 +198,7 @@ public function findShell($shell) {
protected function _shellExists($shell) {
$class = array_map('Cake\Utility\Inflector::camelize', explode('.', $shell));
$class = implode('.', $class);
$class = App::className($class, 'Console/Command', 'Shell');
$class = App::className($class, 'Shell', 'Shell');
if (class_exists($class)) {
return $class;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Console/TaskRegistry.php
Expand Up @@ -48,7 +48,7 @@ public function __construct(Shell $Shell) {
* @return string|false Either the correct classname or false.
*/
protected function _resolveClassName($class) {
return App::className($class, 'Console/Command/Task', 'Task');
return App::className($class, 'Shell/Task', 'Task');
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/Console/Command/BakeShell.php → src/Shell/BakeShell.php
Expand Up @@ -12,7 +12,7 @@
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command;
namespace Cake\Shell;

use Cake\Cache\Cache;
use Cake\Console\Shell;
Expand Down Expand Up @@ -92,11 +92,11 @@ public function main() {
* Locate the tasks bake will use.
*
* Scans the following paths for tasks that are subclasses of
* Cake\Console\Command\Task\BakeTask:
* Cake\Shell\Task\BakeTask:
*
* - Cake/Console/Command/Task/
* - App/Console/Command/Task/
* - Console/Command/Task for each loaded plugin
* - Cake/Shell/Task/
* - App/Shell/Task/
* - Shell/Task for each loaded plugin
*
* @return void
*/
Expand Down Expand Up @@ -126,7 +126,7 @@ public function loadTasks() {
* @return array Updated tasks.
*/
protected function _findTasks($tasks, $path, $namespace, $prefix = false) {
$path .= 'Console/Command/Task';
$path .= 'Shell/Task';
if (!is_dir($path)) {
return $tasks;
}
Expand Down Expand Up @@ -156,7 +156,7 @@ protected function _findClassFiles($path, $namespace) {
continue;
}
$name = $item->getBasename('.php');
$candidates[] = $namespace . '\Console\Command\Task\\' . $name;
$candidates[] = $namespace . '\Shell\Task\\' . $name;
}
return $candidates;
}
Expand All @@ -177,7 +177,7 @@ protected function _findTaskClasses($files) {
if (!$reflect->isInstantiable()) {
continue;
}
if (!$reflect->isSubclassOf('Cake\Console\Command\Task\BakeTask')) {
if (!$reflect->isSubclassOf('Cake\Shell\Task\BakeTask')) {
continue;
}
$classes[] = $className;
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 2.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command;
namespace Cake\Shell;

use Cake\Console\ConsoleOutput;
use Cake\Console\Shell;
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 2.5.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command;
namespace Cake\Shell;

use Cake\Console\Shell;

Expand Down
Expand Up @@ -14,7 +14,7 @@
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command;
namespace Cake\Shell;

use Cake\Console\Shell;

Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command;
namespace Cake\Shell;

use Cake\Cache\Cache;
use Cake\Console\Shell;
Expand Down
Expand Up @@ -13,7 +13,7 @@
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/

namespace Cake\Console\Command;
namespace Cake\Shell;

use Cake\Console\Shell;
use Cake\Core\Configure;
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 1.3.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Cache\Cache;
use Cake\Console\Shell;
Expand Down
Expand Up @@ -12,9 +12,9 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Command\Task\SimpleBakeTask;
use Cake\Shell\Task\SimpleBakeTask;

/**
* Behavior code generator.
Expand Down
Expand Up @@ -12,9 +12,9 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Command\Task\SimpleBakeTask;
use Cake\Shell\Task\SimpleBakeTask;

/**
* Task for creating cells.
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 2.5.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\ConsoleOptionParser;
use Cake\Console\Shell;
Expand Down Expand Up @@ -41,18 +41,18 @@ public function getShellList() {
$plugins = Plugin::loaded();
$shellList = array_fill_keys($plugins, null) + ['CORE' => null, 'app' => null];

$corePath = App::core('Console/Command');
$corePath = App::core('Shell');
$shells = $this->_scanDir($corePath[0]);
$shells = array_diff($shells, $skipFiles, $hiddenCommands);
$shellList = $this->_appendShells('CORE', $shells, $shellList);

$appPath = App::path('Console/Command');
$appPath = App::path('Shell');
$appShells = $this->_scanDir($appPath[0]);
$appShells = array_diff($appShells, $shells, $skipFiles);
$shellList = $this->_appendShells('app', $appShells, $shellList);

foreach ($plugins as $plugin) {
$pluginPath = Plugin::classPath($plugin) . 'Console' . DS . 'Command';
$pluginPath = Plugin::classPath($plugin) . 'Shell';
$pluginShells = $this->_scanDir($pluginPath);
$shellList = $this->_appendShells($plugin, $pluginShells, $shellList);
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public function getShell($commandName) {

$name = Inflector::camelize($name);
$pluginDot = Inflector::camelize($pluginDot);
$class = App::className($pluginDot . $name, 'Console/Command', 'Shell');
$class = App::className($pluginDot . $name, 'Shell', 'Shell');
if (!$class) {
return false;
}
Expand Down
Expand Up @@ -12,9 +12,9 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Command\Task\SimpleBakeTask;
use Cake\Shell\Task\SimpleBakeTask;

/**
* Component code generator.
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Shell;
use Cake\Core\Configure;
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Shell;
use Cake\Core\App;
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 1.3.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Shell;
use Cake\Core\Configure;
Expand Down
Expand Up @@ -12,9 +12,9 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Command\Task\SimpleBakeTask;
use Cake\Shell\Task\SimpleBakeTask;

/**
* Helper code generator.
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Shell;
use Cake\Core\Configure;
Expand Down
Expand Up @@ -12,9 +12,9 @@
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Command\Task\BakeTask;
use Cake\Shell\Task\BakeTask;
use Cake\Console\Shell;
use Cake\Core\App;
use Cake\Utility\File;
Expand Down Expand Up @@ -101,7 +101,7 @@ public function bake($plugin) {
$classBase . DS . 'Model' . DS . 'Behavior',
$classBase . DS . 'Model' . DS . 'Table',
$classBase . DS . 'Model' . DS . 'Entity',
$classBase . DS . 'Console' . DS . 'Command' . DS . 'Task',
$classBase . DS . 'Shell' . DS . 'Task',
$classBase . DS . 'Controller' . DS . 'Component',
$classBase . DS . 'View' . DS . 'Helper',
$classBase . DS . 'Template',
Expand Down
Expand Up @@ -12,9 +12,9 @@
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Command\Task\BakeTask;
use Cake\Shell\Task\BakeTask;
use Cake\Utility\Folder;

/**
Expand Down
Expand Up @@ -12,9 +12,9 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Command\Task\SimpleBakeTask;
use Cake\Shell\Task\SimpleBakeTask;

/**
* Shell code generator.
Expand All @@ -26,7 +26,7 @@ class ShellTask extends SimpleBakeTask {
*
* @var string
*/
public $pathFragment = 'Console/Command/';
public $pathFragment = 'Shell/';

/**
* {@inheritDoc}
Expand Down
Expand Up @@ -12,9 +12,9 @@
* @since 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Command\Task\BakeTask;
use Cake\Shell\Task\BakeTask;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\Utility\Inflector;
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 1.3.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Shell;
use Cake\Core\App;
Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 1.3.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Shell;
use Cake\Controller\Controller;
Expand Down Expand Up @@ -52,7 +52,7 @@ class TestTask extends BakeTask {
'Component' => 'Controller\Component',
'Behavior' => 'Model\Behavior',
'Helper' => 'View\Helper',
'Shell' => 'Console\Command',
'Shell' => 'Shell',
'Cell' => 'View\Cell',
];

Expand Down
Expand Up @@ -12,7 +12,7 @@
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command\Task;
namespace Cake\Shell\Task;

use Cake\Console\Shell;
use Cake\Core\App;
Expand Down
Expand Up @@ -16,7 +16,7 @@
* @since 1.2.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Console\Command;
namespace Cake\Shell;

use Cake\Console\ConsoleOptionParser;
use Cake\Console\Shell;
Expand Down
3 changes: 2 additions & 1 deletion src/Template/Bake/default/classes/shell.ctp
Expand Up @@ -15,7 +15,7 @@

echo "<?php\n";
?>
namespace <?= $namespace ?>\Console\Command;
namespace <?= $namespace ?>\Shell;

use Cake\Console\Shell;

Expand All @@ -31,4 +31,5 @@ class <?= $name ?>Shell extends Shell {
*/
public function main() {
}

}

0 comments on commit 6b02f80

Please sign in to comment.