AclExtras::aco_update PHP Метод

aco_update() публичный Метод

Updates the Aco Tree with new controller actions.
public aco_update ( $params = [] ) : void
Результат void
    public function aco_update($params = array())
    {
        $root = $this->_checkNode($this->rootNode, $this->rootNode, null);
        if (empty($params['plugin'])) {
            $controllers = $this->getControllerList();
            $this->_updateControllers($root, $controllers);
            $plugins = CakePlugin::loaded();
        } else {
            $plugin = $params['plugin'];
            if (!in_array($plugin, App::objects('plugin')) || !CakePlugin::loaded($plugin)) {
                $this->err(__('<error>Plugin %s not found or not activated</error>', $plugin));
                return false;
            }
            $plugins = array($params['plugin']);
        }
        foreach ($plugins as $plugin) {
            $controllers = $this->getControllerList($plugin);
            $path = $this->rootNode . '/' . $plugin;
            $pluginRoot = $this->_checkNode($path, $plugin, $root['Aco']['id']);
            $this->_updateControllers($pluginRoot, $controllers, $plugin);
        }
        $this->out(__('<success>Aco Update Complete</success>'));
        return true;
    }

Usage Example

 /**
  * admin_generate
  */
 public function admin_generate()
 {
     App::uses('AclExtras', 'Acl.Lib');
     $AclExtras = new AclExtras();
     $AclExtras->startup($this);
     if (isset($this->request->named['sync'])) {
         $result = $AclExtras->aco_sync();
     } else {
         $result = $AclExtras->aco_update();
     }
     $output = $AclExtras->output;
     $output += $AclExtras->errors;
     if ($result) {
         $class = 'success';
         $output[] = __d('croogo', 'Created %d new permissions', $AclExtras->created);
     } else {
         $class = 'error';
     }
     $this->Session->setFlash(join('<br>', $output), 'flash', array('class' => $class));
     if (isset($this->request->params['named']['permissions'])) {
         return $this->redirect(array('plugin' => 'acl', 'controller' => 'acl_permissions', 'action' => 'index'));
     } else {
         return $this->redirect(array('action' => 'index'));
     }
 }