| Conditions | 4 |
| Paths | 6 |
| Total Lines | 16 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 39 | public function prePersist(LifecycleEventArgs $args) |
||
| 40 | { |
||
| 41 | /** @var TenantAwareInterface $object */ |
||
| 42 | $object = $args->getObject(); |
||
| 43 | |||
| 44 | // lazy loading to solve circular reference exception |
||
| 45 | if ($this->tenantResolver == null) { |
||
| 46 | $this->tenantResolver = $this->container->get('tahoe.multi_tenancy.tenant_resolver'); |
||
| 47 | } |
||
| 48 | |||
| 49 | if ($object instanceof TenantAwareInterface) { |
||
| 50 | if ($object->getTenant() === null) { |
||
| 51 | $object->setTenant($this->tenantResolver->getTenant()); |
||
| 52 | } |
||
| 53 | } |
||
| 54 | } |
||
| 55 | } |