markstory/acl_extras — Issue #12: acl_sync delete all Plugins and add it back
Author: lamanabie
Created: 2011-12-15 20:04:00+00:00
State: open

I run command from shell: ./Console/cake AclExtras.AclExtras aco_sync -v
Output:
Deleted controllers/AclExtras and all children
Deleted controllers/AclManager and all children
Created Aco node: controllers/AclExtras
Created Aco node: controllers/AclManager
Created Aco node: controllers/AclManager/Acl
Created Aco node: controllers/AclManager/Acl/drop
Created Aco node: controllers/AclManager/Acl/drop_perms
Created Aco node: controllers/AclManager/Acl/index
Created Aco node: controllers/AclManager/Acl/permissions
Created Aco node: controllers/AclManager/Acl/sync_acos
Created Aco node: controllers/AclManager/Acl/update_acos
Created Aco node: controllers/AclManager/Acl/update_acos2
Created Aco node: controllers/AclManager/Acl/update_aros

I dont remove plugins above, acl_extras just delete them and after that add it back .. it makes no sense.
I fix it by editing function _updateControllers,
I edit only this part.
if ($this->_clean) {
if (!$plugin) {
$plugins = App::objects('plugin', null, false);
foreach($plugins as &$one) {
$one = $one.'Plugin';
}
$controllers = array_merge($controllers, $plugins);
}

$controllerFlip = array_flip($controllers);

$this->Aco->id = $root['Aco']['id'];
$controllerNodes = $this->Aco->children(null, true);

foreach ($controllerNodes as $ctrlNode) {
$name = $ctrlNode['Aco']['alias']. 'Controller';
$plugin_name = $ctrlNode['Aco']['alias']. 'Pluginn';

if (!isset($controllerFlip[$name]) && !isset($controllerFlip[$plugin_name] )) {

if ($this->Aco->delete($ctrlNode['Aco']['id'])) {
$this->out(__(
'Deleted %s and all children',
$this->rootNode . '/' . $ctrlNode['Aco']['alias']
), 1, Shell::VERBOSE);
}
}
}
}

After that plugin remove plugin and controllers only when they are really removed from Plugin folder.