Пример #1
0
 public function testDummyAclAdapter()
 {
     $options = array('cache' => array('storage' => '???', 'options' => array('ttl' => 300)));
     $acl = Acl::getInstance('dummy', $options);
     $this->assertNotNull($acl);
     $this->assertTrue($acl->isAllowed(array('test' => 'test')));
 }
Пример #2
0
 /**
  * Create service
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @return mixed
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $options = $serviceLocator->get('Configuration');
     $options = $options['dao-acl'];
     $adapter = $options['adapter'];
     $options = $options['options'];
     if ($adapter === 'doctrine') {
         if (is_string($options['entity_manager'])) {
             $options['entity_manager'] = $serviceLocator->get($options['entity_manager']);
         }
     }
     try {
         $acl = \Acl\Acl::getInstance($adapter, $options);
         return $acl;
     } catch (RuntimeException $re) {
         $acl = \Acl\Acl::getInstance();
         return $acl;
     }
 }
Пример #3
0
 /**
  * Check if role can access to this resource
  * @param Acl\Role $role The role to check
  * @return boolean Allow or deny
  */
 public function isAllowed(Role $role)
 {
     $acl = Acl::getInstance();
     return $acl->isAllowed($role, $this);
 }
Пример #4
0
 /**
  * Check if this role can access to the resource
  * @param Acl\Resource|string $resource The resource or his name
  * @return boolean Allow or deny
  */
 public function isAllowed($resource)
 {
     $acl = Acl::getInstance();
     return $acl->isAllowed($this, $resource);
 }