/**
  * {@inheritDoc}
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     $this->_permissions = $registry->getController()->permissions ?: [];
     $this->_controller = $registry->getController();
     $this->_roles = TableRegistry::get($this->config('rolesModel'));
 }
 /**
  * Autoload permission configuration
  * @param ComponentRegistry $registry component registry
  * @param array $config config
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     $autoload = $this->config('autoload_config');
     if ($autoload) {
         $loadedPermissions = $this->_loadPermissions($autoload, 'default');
         $this->config('permissions', $loadedPermissions);
     }
 }
 /**
  * TinyAuthorize::__construct()
  *
  * @param \Cake\Controller\ComponentRegistry $registry
  * @param array $config
  * @throws \Cake\Core\Exception\Exception
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     $config += (array) Configure::read('TinyAuth');
     $config += $this->_defaultConfig;
     if (!$config['prefixes'] && !empty($config['authorizeByPrefix'])) {
         throw new Exception('Invalid TinyAuthorization setup for `authorizeByPrefix`. Please declare `prefixes`.');
     }
     parent::__construct($registry, $config);
     if (!in_array($config['cache'], Cache::configured())) {
         throw new Exception(sprintf('Invalid TinyAuthorization cache `%s`', $config['cache']));
     }
 }
 /**
  * @param ComponentRegistry $registry The controller for this request.
  * @param array $config An array of config. This class does not use any config.
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     if (!file_exists(CONFIG . $this->config('hierarchyFile'))) {
         throw new Exception(sprintf("Provided hierarchy config file %s doesn't exist.", $this->config('hierarchyFile')));
     }
     if (!file_exists(CONFIG . $this->config('aclFile'))) {
         throw new Exception(sprintf("Provided ACL config file %s doesn't exist.", $this->config('aclFile')));
     }
     // caching
     $hierarchyModified = filemtime(CONFIG . $this->config('hierarchyFile'));
     $aclModified = filemtime(CONFIG . $this->config('aclFile'));
     $lastModified = $hierarchyModified > $aclModified ? $hierarchyModified : $aclModified;
     if (Cache::read('hierarchy_auth_build_time') < $lastModified) {
         $this->_hierarchy = $this->_getHierarchy();
         $this->_acl = $this->_getAcl();
         Cache::write('hierarchy_auth_cache', ['acl' => $this->_acl, 'hierarchy' => $this->_hierarchy]);
         Cache::write('hierarchy_auth_build_time', time());
     } else {
         $cache = Cache::read('hierarchy_auth_cache');
         $this->_hierarchy = $cache['hierarchy'];
         $this->_acl = $cache['acl'];
     }
 }
 /**
  * @param \Cake\Controller\ComponentRegistry $registry
  * @param array $config
  * @throws \Cake\Core\Exception\Exception
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     $config = $this->_prepareConfig($config);
     parent::__construct($registry, $config);
 }
 /**
  * {@inheritDoc}
  */
 public function __construct(ComponentRegistry $registry, array $config = [])
 {
     parent::__construct($registry, $config);
     $this->controller($registry->getController());
 }