/** * Transform a given ACL entry into a Entry model. * * The entry will not be persisted! * * @param \Symfony\Component\Security\Acl\Model\EntryInterface $aclEntry * * @return \Propel\Bundle\PropelBundle\Model\Acl\Entry */ public static function fromAclEntry(EntryInterface $aclEntry) { $entry = new self(); // Already persisted before? if ($aclEntry->getId()) { $entry->setId($aclEntry->getId()); } $entry->setMask($aclEntry->getMask())->setGranting($aclEntry->isGranting())->setGrantingStrategy($aclEntry->getStrategy())->setSecurityIdentity(SecurityIdentity::fromAclIdentity($aclEntry->getSecurityIdentity())); if ($aclEntry instanceof FieldEntryInterface) { $entry->setFieldName($aclEntry->getField()); } if ($aclEntry instanceof AuditableEntryInterface) { $entry->setAuditFailure($aclEntry->isAuditFailure())->setAuditSuccess($aclEntry->isAuditSuccess()); } return $entry; }
/** * Retrieve the persisted model for the given ACE. * * If none is given, null is returned. * * @param \Symfony\Component\Security\Acl\Model\EntryInterface $ace * * @return \Propel\Bundle\PropelBundle\Model\Acl\Entry|null */ protected function getPersistedAce(EntryInterface $ace, ObjectIdentity $objectIdentity, $object = false) { if (null !== $ace->getId() and null !== ($entry = EntryQuery::create()->findPk($ace->getId(), $this->connection))) { $entry->reload(true, $this->connection); return $entry; } /* * The id is not set, but there may be an ACE in the database. * * This happens if the ACL has created new ACEs, but was not reloaded. * We try to retrieve one by the unique key. */ $ukQuery = EntryQuery::create()->filterByAclClass($objectIdentity->getAclClass($this->connection))->filterBySecurityIdentity(SecurityIdentity::fromAclIdentity($ace->getSecurityIdentity(), $this->connection)); if (true === $object) { $ukQuery->filterByObjectIdentity($objectIdentity); } else { $ukQuery->filterByObjectIdentityId(null, Criteria::ISNULL); } if ($ace instanceof FieldEntryInterface) { $ukQuery->filterByFieldName($ace->getField()); } else { $ukQuery->filterByFieldName(null, Criteria::ISNULL); } return $ukQuery->findOne($this->connection); }