/** * Filter by an ObjectIdentity object belonging to the given ACL related ObjectIdentity. * * @param \Symfony\Component\Security\Acl\Model\ObjectIdentityInterface $objectIdentity * @param ConnectionInterface $con * * @return \Propel\Bundle\PropelBundle\Model\Acl\ObjectIdentityQuery $this */ public function filterByAclObjectIdentity(ObjectIdentityInterface $objectIdentity, ConnectionInterface $con = null) { /* * Not using a JOIN here, because the filter may be applied on 'findOneOrCreate', * which is currently (Propel 1.6.4-dev) not working. */ $aclClass = AclClass::fromAclObjectIdentity($objectIdentity, $con); $this->filterByClassId($aclClass->getId())->filterByIdentifier($objectIdentity->getIdentifier()); return $this; }
public function testFromAclObjectIdentity() { $type = 'Merchant'; $aclClass = AclClass::fromAclObjectIdentity(new ObjectIdentity(5, $type), $this->con); $this->assertInstanceOf('Propel\\Bundle\\PropelBundle\\Model\\Acl\\AclClass', $aclClass); $this->assertEquals($type, $aclClass->getType()); $dbEntry = AclClassQuery::create()->findOne($this->con); $this->assertInstanceOf('Propel\\Bundle\\PropelBundle\\Model\\Acl\\AclClass', $dbEntry); $this->assertEquals($type, $dbEntry->getType()); $this->assertEquals($dbEntry->getId(), $aclClass->getId()); }
public function testFilterByAclObjectIdentity() { $aclObj = new ObjectIdentity(1, 'Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\Model\\Book'); $aclClass = AclClass::fromAclObjectIdentity($aclObj, $this->con); $this->assertInstanceOf('Propel\\Bundle\\PropelBundle\\Model\\Acl\\AclClass', $aclClass); // None given. $result = ObjectIdentityQuery::create()->filterByAclObjectIdentity($aclObj, $this->con)->find($this->con); $this->assertCount(0, $result); $this->createModelObjectIdentity(1); $result = ObjectIdentityQuery::create()->filterByAclObjectIdentity($aclObj, $this->con)->find($this->con); $this->assertCount(1, $result); $this->assertEquals($aclClass->getId(), $result->getFirst()->getClassId()); $this->assertEquals(1, $result->getFirst()->getIdentifier()); // Change the entity. $aclObj = new ObjectIdentity(2, 'Propel\\Bundle\\PropelBundle\\Tests\\Fixtures\\Model\\Book'); $result = ObjectIdentityQuery::create()->filterByAclObjectIdentity($aclObj, $this->con)->find($this->con); $this->assertCount(0, $result); }
protected function getAclClass() { return AclClass::fromAclObjectIdentity($this->getAclObjectIdentity(), $this->con); }