Acl\Controller\Component\AclComponent::__construct PHP Method

__construct() public method

Constructor. Will return an instance of the correct ACL class as defined in Configure::read('Acl.classname')
public __construct ( Cake\Controller\ComponentRegistry $collection, array $config = [] )
$collection Cake\Controller\ComponentRegistry A ComponentRegistry
$config array Array of configuration settings
    public function __construct(ComponentRegistry $collection, array $config = [])
    {
        parent::__construct($collection, $config);
        $className = $name = Configure::read('Acl.classname');
        if (!class_exists($className)) {
            $className = App::className('Acl.' . $name, 'Adapter');
            if (!$className) {
                throw new Exception(sprintf('Could not find {0}.', [$name]));
            }
        }
        $this->adapter($className);
    }

Usage Example

 /**
  * Constructor. Will return an instance of the correct ACL class as defined in `Configure::read('Acl.classname')`
  *
  * @param ComponentRegistry $collection A ComponentRegistry
  * @param array $config Array of configuration settings
  * @throws \Cake\Core\Exception\Exception when Acl.classname could not be loaded.
  */
 public function __construct(ComponentRegistry $collection, array $config = [])
 {
     parent::__construct($collection, $config);
     $className = $name = Configure::read('Acl.classname');
     if (!class_exists($className)) {
         $className = App::className('Acl.' . $name, 'Adapter');
         if (!$className) {
             throw new Exception(sprintf('Could not find {0}.', [$name]));
         }
     }
     $this->adapter($className);
 }