| Conditions | 4 |
| Paths | 4 |
| Total Lines | 28 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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 | |||
| 48 | $entityManager->persist($entity); |
||
| 49 | $metadata = $entityManager->getClassMetadata(get_class($entity)); |
||
| 50 | $unitOfWork->recomputeSingleEntityChangeSet($metadata, $entity); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 |