Acl\AclExtras::startup PHP Method

startup() public method

Start up And load Acl Component / Aco model
public startup ( Controller $controller = null ) : void
$controller Cake\Controller\Controller Controller instance
return void
    public function startup($controller = null)
    {
        if (!$controller) {
            $controller = new Controller(new Request());
        }
        $registry = new ComponentRegistry();
        $this->Acl = new AclComponent($registry, Configure::read('Acl'));
        $this->Aco = $this->Acl->Aco;
        $this->controller = $controller;
        $this->_buildPrefixes();
    }

Usage 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']);
 }