Phalcon\Acl\Factory\Memory::create PHP Method

create() public method

Creates configured instance of acl.
public create ( Phalcon\Config $config ) : Phalcon\Acl\Adapter\Memory
$config Phalcon\Config config
return Phalcon\Acl\Adapter\Memory acl
    public function create(Config $config)
    {
        $this->acl = new MemoryAdapter();
        $this->config = $config;
        $defaultAction = $this->config->get('defaultAction');
        if (!is_int($defaultAction) && !ctype_digit($defaultAction)) {
            throw new Exception('Key "defaultAction" must exist and must be of numeric value.');
        }
        $this->acl->setDefaultAction((int) $defaultAction);
        $this->addResources();
        $this->addRoles();
        return $this->acl;
    }

Usage Example

Beispiel #1
0
 /**
  * @expectedException \Phalcon\Acl\Exception
  * @expectedExceptionMessage Role "user" cannot inherit non-existent role "nonexistentrole".
  * Either such role does not exist or it is set to be inherited before it is actually defined.
  */
 public function testFactoryShouldThrowExceptionIfNonExistentInheritRoleIsSet()
 {
     $config = new Ini(INCUBATOR_FIXTURES . 'Acl/acl.ini');
     $config->acl->role->user->inherit = 'nonexistentrole';
     $factory = new MemoryFactory();
     $factory->create($config->get('acl'));
 }