Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function insertPermission(PermissionInterface $permission)
 {
     $sth = $this->getPdoStatement('INSERT INTO ' . $this->getAclSchema()->getPermissionsTableName() . ' (requester, resource, mask) VALUES (:requester, :resource, :mask)');
     $sth->bindValue(':mask', $permission->getMask(), PDO::PARAM_INT);
     $sth->bindValue(':requester', $permission->getRequester()->getAclRequesterIdentifier(), PDO::PARAM_STR);
     $sth->bindValue(':resource', $permission->getResource()->getAclResourceIdentifier(), PDO::PARAM_STR);
     $sth->execute();
 }
Esempio n. 2
0
 /**
  * @dataProvider isGrantedMaskComparisonProvider
  */
 public function testIsGrantedMaskComparison($action, $requiredMask, $mask, $result)
 {
     $this->maskBuilder->resolveMask(Argument::exact($action))->willReturn($requiredMask);
     $this->maskBuilder->get()->willReturn($mask);
     if ($result) {
         $this->assertTrue($this->permission->isGranted($action));
     } else {
         $this->assertfalse($this->permission->isGranted($action));
     }
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function remove(PermissionInterface $permission)
 {
     $cacheId = $this->getCacheId($permission->getRequester(), $permission->getResource());
     $this->cacheProvider->delete($cacheId);
     return $this;
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function insertPermission(PermissionInterface $permission)
 {
     $this->connection->insert('INSERT INTO ' . $this->getAclSchema()->getPermissionsTableName() . ' (requester, resource, mask) VALUES (:requester, :resource, :mask)', ['requester' => $permission->getRequester()->getAclRequesterIdentifier(), 'resource' => $permission->getResource()->getAclResourceIdentifier(), 'mask' => $permission->getMask()]);
 }
Esempio n. 5
0
 /**
  * {@inheritdoc}
  */
 public function insertPermission(PermissionInterface $permission)
 {
     $this->connection->insert($this->getAclSchema()->getPermissionsTableName(), ['requester' => $permission->getRequester()->getAclRequesterIdentifier(), 'resource' => $permission->getResource()->getAclResourceIdentifier(), 'mask' => $permission->getMask()], ['mask' => \PDO::PARAM_INT, 'requester' => \PDO::PARAM_STR, 'resource' => \PDO::PARAM_STR]);
 }
Esempio n. 6
0
 /**
  * {@inheritdoc}
  */
 public function insertPermission(PermissionInterface $permission)
 {
     $this->connection->insert($this->getAclSchema()->getPermissionsTableName(), ['requester' => $permission->getRequester()->getAclRequesterIdentifier(), 'resource' => $permission->getResource()->getAclResourceIdentifier(), 'mask' => $permission->getMask()], ['mask' => 'integer', 'requester' => 'string', 'resource' => 'string']);
 }
Esempio n. 7
0
File: Acl.php Progetto: alexdpy/acl
 /**
  * @param PermissionInterface $permission
  */
 protected function savePermission(PermissionInterface $permission)
 {
     if (0 === $permission->getMask()) {
         if ($permission->isPersistent()) {
             $this->databaseProvider->deletePermission($permission);
             $permission->setPersistent(false);
         }
         $this->permissionBuffer->add($permission);
         return;
     }
     if ($permission->isPersistent()) {
         $this->databaseProvider->updatePermission($permission);
     } else {
         $this->databaseProvider->insertPermission($permission);
         $permission->setPersistent(true);
     }
     $this->permissionBuffer->add($permission);
 }