Skip to content

Commit a041857

Browse files
committed
Optimized ACL rebuild
1 parent 848aee2 commit a041857

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/ACL.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,11 @@ public function processNewResource(EntityResource $resource)
161161
*/
162162
public function rebuildAuthorizations()
163163
{
164-
$authorizationRepository = $this->entityManager->getRepository('MyCLabs\ACL\Model\Authorization');
165164
$roleRepository = $this->entityManager->getRepository('MyCLabs\ACL\Model\Role');
166165

167166
// Clear
168-
// TODO use DQL DELETE query
169-
foreach ($authorizationRepository->findAll() as $authorization) {
170-
$this->entityManager->remove($authorization);
171-
}
172-
$this->entityManager->flush();
173-
$this->entityManager->clear();
167+
$this->entityManager->createQuery('DELETE MyCLabs\ACL\Model\Authorization');
168+
$this->entityManager->clear('MyCLabs\ACL\Model\Authorization');
174169

175170
// Regenerate
176171
foreach ($roleRepository->findAll() as $role) {

0 commit comments

Comments
 (0)