| Conditions | 7 |
| Paths | 5 |
| Total Lines | 24 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | * @param OnFlushEventArgs $onFlushEventArgs |
||
| 24 | */ |
||
| 25 | public function onFlush(OnFlushEventArgs $onFlushEventArgs) |
||
| 26 | { |
||
| 27 | $entityManager = $onFlushEventArgs->getEntityManager(); |
||
| 28 | $unitOfWork = $entityManager->getUnitOfWork(); |
||
| 29 | |||
| 30 | $entities = array_merge( |
||
| 31 | $unitOfWork->getScheduledEntityInsertions(), |
||
| 32 | $unitOfWork->getScheduledEntityUpdates() |
||
| 33 | ); |
||
| 34 | |||
| 35 | foreach ($entities as $entity) { |
||
| 36 | if (!$entity instanceof UserAclOwnerAwareInterface) { |
||
| 37 | continue; |
||
| 38 | } |
||
| 39 | |||
| 40 | if (!$owner = $entity->getAclOwner()) { |
||
| 41 | throw new \RuntimeException("Not found AclOwner for: " . get_class($entity)); |
||
| 42 | } |
||
| 43 | |||
| 44 | $this->container->get('oneup_acl.manager') |
||
| 45 | ->addObjectPermission($entity, MaskBuilder::MASK_OWNER, $owner) |
||
| 46 | ; |
||
| 47 | |||
| 54 |