2013-12-12 17:48:16 +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
*/
2016-02-11 19:14:03 +01:00
namespace Propel\Bundle\PropelBundle\Model\Acl ;
2013-12-12 17:48:16 +01:00
2016-02-11 19:14:03 +01:00
use Propel\Bundle\PropelBundle\Model\Acl\Base\EntryQuery as BaseEntryQuery ;
use Propel\Bundle\PropelBundle\Model\Acl\Map\EntryTableMap ;
use Propel\Bundle\PropelBundle\Model\Acl\Map\ObjectIdentityTableMap ;
2013-12-12 17:48:16 +01:00
use Propel\Runtime\ActiveQuery\Criteria ;
use Propel\Runtime\Connection\ConnectionInterface ;
use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface ;
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface ;
class EntryQuery extends BaseEntryQuery
{
/**
* Return Entry objects filtered by an ACL related ObjectIdentity .
*
* @ see find ()
*
* @ param \Symfony\Component\Security\Acl\Model\ObjectIdentityInterface $objectIdentity An ACL related ObjectIdentity .
* @ param array $securityIdentities A list of SecurityIdentity to filter by .
2013-12-14 13:47:55 +01:00
* @ param \ConnectionInterface $con
2013-12-12 17:48:16 +01:00
*
* @ return \PropelObjectCollection
*/
public function findByAclIdentity ( ObjectIdentityInterface $objectIdentity , array $securityIdentities = array (), ConnectionInterface $con = null )
{
$securityIds = array ();
foreach ( $securityIdentities as $eachIdentity ) {
if ( ! $eachIdentity instanceof SecurityIdentityInterface ) {
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 );
}
throw new \InvalidArgumentException ( $errorMessage );
}
if ( $securityIdentity = SecurityIdentity :: fromAclIdentity ( $eachIdentity )) {
$securityIds [ $securityIdentity -> getId ()] = $securityIdentity -> getId ();
}
}
$this
-> useAclClassQuery ( null , Criteria :: INNER_JOIN )
-> filterByType (( string ) $objectIdentity -> getType ())
-> endUse ()
-> leftJoinObjectIdentity ()
2014-04-19 05:42:00 +02:00
-> add ( ObjectIdentityTableMap :: COL_OBJECT_IDENTIFIER , ( string ) $objectIdentity -> getIdentifier (), Criteria :: EQUAL )
-> addOr ( EntryTableMap :: COL_OBJECT_IDENTITY_ID , null , Criteria :: ISNULL )
2013-12-12 17:48:16 +01:00
;
if ( ! empty ( $securityIdentities )) {
$this -> filterBySecurityIdentityId ( $securityIds );
}
return $this -> find ( $con );
}
}