Skip to content

Commit

Permalink
Optimized ACL rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Jun 18, 2014
1 parent 848aee2 commit a041857
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/ACL.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,11 @@ public function processNewResource(EntityResource $resource)
*/
public function rebuildAuthorizations()
{
$authorizationRepository = $this->entityManager->getRepository('MyCLabs\ACL\Model\Authorization');
$roleRepository = $this->entityManager->getRepository('MyCLabs\ACL\Model\Role');

// Clear
// TODO use DQL DELETE query
foreach ($authorizationRepository->findAll() as $authorization) {
$this->entityManager->remove($authorization);
}
$this->entityManager->flush();
$this->entityManager->clear();
$this->entityManager->createQuery('DELETE MyCLabs\ACL\Model\Authorization');
$this->entityManager->clear('MyCLabs\ACL\Model\Authorization');

// Regenerate
foreach ($roleRepository->findAll() as $role) {
Expand Down

0 comments on commit a041857

Please sign in to comment.