Ejemplo n.º 1
0
 /**
  * Update auditing on a single ACE.
  *
  * @throws \InvalidArgumentException
  *
  * @param array $list
  * @param int   $index
  * @param bool  $auditSuccess
  * @param bool  $auditFailure
  *
  * @return \Propel\Bundle\PropelBundle\Security\Acl\Domain\AuditableAcl $this
  */
 protected function updateAuditing(array &$list, $index, $auditSuccess, $auditFailure)
 {
     if (!is_bool($auditSuccess) or !is_bool($auditFailure)) {
         throw new \InvalidArgumentException('The given auditing flags are invalid. Please provide boolean only.');
     }
     $this->validateIndex($list, $index);
     $entry = ModelEntry::fromAclEntry($list[$index])->setAuditSuccess($auditSuccess)->setAuditFailure($auditFailure);
     $list[$index] = ModelEntry::toAclEntry($entry, $this);
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * @depends testToAclEntry
  */
 public function testFromAclEntry($aclEntry)
 {
     $modelEntry = ModelEntry::fromAclEntry($aclEntry);
     $this->assertInstanceOf('Propel\\Bundle\\PropelBundle\\Model\\Acl\\Entry', $modelEntry);
     $this->assertEquals(42, $modelEntry->getId());
     $this->assertTrue($modelEntry->getAuditFailure());
     $this->assertFalse($modelEntry->getAuditSuccess());
     $this->assertEquals('all', $modelEntry->getGrantingStrategy());
     $this->assertTrue($modelEntry->getGranting());
     $this->assertEquals(64, $modelEntry->getMask());
 }
Ejemplo n.º 3
0
 /**
  * Persist the given ACEs.
  *
  * @param array                                                $accessControlEntries
  * @param \Propel\Bundle\PropelBundle\Model\Acl\ObjectIdentity $objectIdentity
  * @param bool                                                 $object
  *
  * @return array The IDs of the persisted ACEs.
  */
 protected function persistAcl(array $accessControlEntries, ObjectIdentity $objectIdentity, $object = false)
 {
     $entries = array();
     /* @var $eachAce \Symfony\Component\Security\Acl\Model\EntryInterface */
     foreach ($accessControlEntries as $order => $eachAce) {
         // If the given ACE has never been persisted, create a new one.
         if (null === ($entry = $this->getPersistedAce($eachAce, $objectIdentity, $object))) {
             $entry = ModelEntry::fromAclEntry($eachAce);
         }
         if (in_array($entry->getId(), $entries)) {
             $entry = ModelEntry::fromAclEntry($eachAce);
         }
         // Apply possible changes from local ACE.
         $entry->setAceOrder($order)->setAclClass($objectIdentity->getAclClass())->setMask($eachAce->getMask());
         if ($eachAce instanceof AuditableEntryInterface) {
             if (is_bool($eachAce->isAuditSuccess())) {
                 $entry->setAuditSuccess($eachAce->isAuditSuccess());
             }
             if (is_bool($eachAce->isAuditFailure())) {
                 $entry->setAuditFailure($eachAce->isAuditFailure());
             }
         }
         if (true === $object) {
             $entry->setObjectIdentity($objectIdentity);
         }
         $entry->save($this->connection);
         $entries[] = $entry->getId();
     }
     return $entries;
 }
Ejemplo n.º 4
0
 /**
  * Update a single ACE of this ACL.
  *
  * @param array  $list
  * @param int    $index
  * @param int    $mask
  * @param string $strategy
  * @param string $field
  *
  * @return \Propel\Bundle\PropelBundle\Security\Acl\Domain\MutableAcl $this
  */
 protected function updateAce(array &$list, $index, $mask, $strategy = null)
 {
     $this->validateIndex($list, $index);
     $entry = ModelEntry::fromAclEntry($list[$index]);
     // Apply updates
     $entry->setMask($mask);
     if (null !== $strategy) {
         $entry->setGrantingStrategy($strategy);
     }
     $list[$index] = ModelEntry::toAclEntry($entry, $this);
     return $this;
 }