kos4live / acldoctrinequery-bundle
Symfony2 Helper Bundle for ACL
Installs: 126
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
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 not auto-updated.
Last update: 2024-12-21 16:10:17 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(),