Acl\AclExtras::acoUpdate PHP Method

acoUpdate() public method

Updates the Aco Tree with new controller actions.
public acoUpdate ( array $params = [] ) : boolean
$params array An array of parameters
return boolean
    public function acoUpdate($params = [])
    {
        $root = $this->_checkNode($this->rootNode, $this->rootNode, null);
        if (empty($params['plugin'])) {
            $plugins = Plugin::loaded();
            $this->_processControllers($root);
            $this->_processPrefixes($root);
            $this->_processPlugins($root, $plugins);
        } else {
            $plugin = $params['plugin'];
            if (!Plugin::loaded($plugin)) {
                $this->err(__d('cake_acl', "<error>Plugin {0} not found or not activated.</error>", [$plugin]));
                return false;
            }
            $plugins = [$params['plugin']];
            $this->_processPlugins($root, $plugins);
            $this->foundACOs = array_slice($this->foundACOs, 1, null, true);
        }
        if ($this->_clean) {
            foreach ($this->foundACOs as $parentId => $acosList) {
                $this->_cleaner($parentId, $acosList);
            }
        }
        $this->out(__d('cake_acl', '<success>Aco Update Complete</success>'));
        return true;
    }

Usage Example

Example #1
0
 /**
  * Build action.
  *
  * @param string $type
  * @trows BadRequestException
  * @return \Cake\Network\Response|null
  */
 public function build($type = 'synchronize')
 {
     if (!Arr::in($type, $this->_buildTypes)) {
         throw new BadRequestException(__d('community', 'Unable to find build type "{0}"', $type));
     }
     $AclExtras = new AclExtras();
     $AclExtras->startup($this);
     if ($type == 'synchronize') {
         $AclExtras->acoSync();
     } else {
         $AclExtras->acoUpdate();
     }
     return $this->redirect(['action' => 'permissions']);
 }