samuel4x4 / acldoctrinequery-bundle
Symfony2 Helper Bundle for ACLs
Installs: 13
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.3
- doctrine/doctrine-bundle: 1.2.*
- doctrine/orm: >=2.2.3,<2.4-dev
- symfony/framework-bundle: ~2.3
This package is auto-updated.
Last update: 2025-01-14 03:34:10 UTC
README
Helper Bundle for Symfony2 ACL
Usage:
$aclQueryHelper = $this->get('kos4live.acl_doctrine_query.helper');
$em = $this->getDoctrine()->getManager();
$qb = $em->createQueryBuilder();
$qb = $qb->select('p')
->from('Entity\Product', 'p');
$qb->setMaxResults(10);
$permissions = array('view');
$user = $this->getUser();
// The returned query object is a clone, you can alway use $qb->getQuery() to get the original query object
$query = $aqlQueryHelper->apply($qb, $permissions, $user);
$result = $query->getArrayResult();
The $user parameter of apply() is optional and if is not set or null, the securityContext would use to determine the current user.
Don't forget add to AppKernel.php new kos4live\AclDoctrineQueryBundle\kos4liveAclDoctrineQueryBundle(),