protected function _updateControllers($root, $controllers, $plugin = null)
{
$dotPlugin = $pluginPath = $plugin;
if ($plugin) {
$dotPlugin .= '.';
$pluginPath .= '/';
}
$appIndex = array_search($plugin . 'AppController', $controllers);
if ($appIndex !== false) {
App::uses($plugin . 'AppController', $dotPlugin . 'Controller');
unset($controllers[$appIndex]);
}
// look at each controller
foreach ($controllers as $controller) {
App::uses($controller, $dotPlugin . 'Controller');
$controllerName = preg_replace('/Controller$/', '', $controller);
$path = $this->rootNode . '/' . $pluginPath . $controllerName;
$controllerNode = $this->_checkNode($path, $controllerName, $root['Aco']['id']);
$this->_checkMethods($controller, $controllerName, $controllerNode, $pluginPath);
}
if ($this->_clean) {
if (!$plugin) {
$controllers = array_merge($controllers, App::objects('plugin', null, false));
}
$controllerFlip = array_flip($controllers);
$this->Aco->id = $root['Aco']['id'];
$controllerNodes = $this->Aco->children(null, true);
foreach ($controllerNodes as $ctrlNode) {
$alias = $ctrlNode['Aco']['alias'];
$name = $alias . 'Controller';
if (!isset($controllerFlip[$name]) && !isset($controllerFlip[$alias])) {
if ($this->Aco->delete($ctrlNode['Aco']['id'])) {
$this->out(__('Deleted %s and all children', $this->rootNode . '/' . $ctrlNode['Aco']['alias']), 1, Shell::VERBOSE);
}
}
}
}
}