/** * @return \Propel\PropelBundle\Model\Acl\ObjectIdentity */ protected function createModelObjectIdentity($identifier) { $aclClass = $this->getAclClass(); $objIdentity = new ModelObjectIdentity(); $this->assertTrue((bool) $objIdentity->setAclClass($aclClass)->setIdentifier($identifier)->save($this->con)); return $objIdentity; }
/** * Constructor. * * @param \PropelObjectCollection $entries * @param \Symfony\Component\Security\Acl\Model\ObjectIdentityInterface $objectIdentity * @param \Symfony\Component\Security\Acl\Model\PermissionGrantingStrategyInterface $permissionGrantingStrategy * @param array $loadedSecurityIdentities * @param \Symfony\Component\Security\Acl\Model\AclInterface $parentAcl * @param bool $inherited * @param \PropelPDO $con */ public function __construct(\PropelObjectCollection $entries, ObjectIdentityInterface $objectIdentity, PermissionGrantingStrategyInterface $permissionGrantingStrategy, array $loadedSecurityIdentities = array(), AclInterface $parentAcl = null, $inherited = true, \PropelPDO $con = null) { parent::__construct($entries, $objectIdentity, $permissionGrantingStrategy, $loadedSecurityIdentities, $parentAcl, $inherited); $this->modelObjectIdentity = ObjectIdentityQuery::create()->filterByAclObjectIdentity($objectIdentity, $con)->findOneOrCreate($con); if ($this->modelObjectIdentity->isNew()) { $this->modelObjectIdentity->save($con); } $this->id = $this->modelObjectIdentity->getId(); $this->con = $con; }
public function testInsertWithAssignedParent() { $parent = $this->createModelObjectIdentity(1); $obj = new ObjectIdentity(); $obj->setAclClass($this->getAclClass())->setIdentifier(2)->setObjectIdentityRelatedByParentObjectIdentityId($parent)->save($this->con); $entries = ObjectIdentityQuery::create()->orderByParentObjectIdentityId(Criteria::ASC)->find($this->con); $this->assertCount(2, $entries); $this->assertNull($entries[0]->getParentObjectIdentityId()); $this->assertEquals($entries[0]->getId(), $entries[1]->getParentObjectIdentityId()); }
/** * 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\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); }