2012-01-12 16:29:33 +01:00
< ? php
/**
* This file is part of the PropelBundle package .
* For the full copyright and license information , please view the LICENSE
* file that was distributed with this source code .
*
* @ license MIT License
*/
namespace Propel\PropelBundle\Model\Acl ;
use Propel\PropelBundle\Model\Acl\om\BaseEntryQuery ;
2012-01-13 18:14:15 +01:00
use Propel\PropelBundle\Model\Acl\EntryPeer ;
use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface ;
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface ;
2012-01-12 16:29:33 +01:00
class EntryQuery extends BaseEntryQuery
{
2012-01-13 18:14:15 +01:00
/**
* Return Entry objects filtered by an ACL related ObjectIdentity .
*
* @ see find ()
*
2012-05-24 12:44:48 +02:00
* @ param \Symfony\Component\Security\Acl\Model\ObjectIdentityInterface $objectIdentity An ACL related ObjectIdentity .
* @ param array $securityIdentities A list of SecurityIdentity to filter by .
* @ param \PropelPDO $con
2012-01-13 18:14:15 +01:00
*
2012-02-04 15:18:44 +01:00
* @ return \PropelObjectCollection
2012-01-13 18:14:15 +01:00
*/
2012-02-04 12:18:55 +01:00
public function findByAclIdentity ( ObjectIdentityInterface $objectIdentity , array $securityIdentities = array (), \PropelPDO $con = null )
2012-01-13 18:14:15 +01:00
{
$securityIds = array ();
foreach ( $securityIdentities as $eachIdentity ) {
if ( ! $eachIdentity instanceof SecurityIdentityInterface ) {
2012-02-02 17:26:13 +01:00
if ( is_object ( $eachIdentity )) {
$errorMessage = sprintf ( 'The list of security identities contains at least one invalid entry of class "%s". Please provide objects of classes implementing "Symfony\Component\Security\Acl\Model\SecurityIdentityInterface" only.' , get_class ( $eachIdentity ));
} else {
$errorMessage = sprintf ( 'The list of security identities contains at least one invalid entry "%s". Please provide objects of classes implementing "Symfony\Component\Security\Acl\Model\SecurityIdentityInterface" only.' , $eachIdentity );
}
2012-02-04 12:18:55 +01:00
throw new \InvalidArgumentException ( $errorMessage );
2012-01-13 18:14:15 +01:00
}
if ( $securityIdentity = SecurityIdentity :: fromAclIdentity ( $eachIdentity )) {
$securityIds [ $securityIdentity -> getId ()] = $securityIdentity -> getId ();
}
}
$this
2012-02-04 12:18:55 +01:00
-> useAclClassQuery ( null , \Criteria :: INNER_JOIN )
2012-01-18 15:30:52 +01:00
-> filterByType (( string ) $objectIdentity -> getType ())
2012-01-13 18:14:15 +01:00
-> endUse ()
2012-01-18 15:30:52 +01:00
-> leftJoinObjectIdentity ()
2012-02-04 12:18:55 +01:00
-> add ( ObjectIdentityPeer :: OBJECT_IDENTIFIER , ( string ) $objectIdentity -> getIdentifier (), \Criteria :: EQUAL )
-> addOr ( EntryPeer :: OBJECT_IDENTITY_ID , null , \Criteria :: ISNULL )
2012-01-13 18:14:15 +01:00
;
if ( ! empty ( $securityIdentities )) {
$this -> filterBySecurityIdentityId ( $securityIds );
}
2012-01-12 16:29:33 +01:00
2012-01-13 18:14:15 +01:00
return $this -> find ( $con );
}
2012-01-12 16:29:33 +01:00
}