| Conditions | 6 |
| Paths | 12 |
| Total Lines | 28 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 34 | public function createService(ServiceLocatorInterface $serviceLocator) |
||
| 35 | { |
||
| 36 | $auth = $serviceLocator->get('AuthenticationService'); |
||
| 37 | $user = $auth->getUser(); |
||
| 38 | $settings = $user->getSettings('Orders'); |
||
| 39 | $invoiceAddress = $settings->getInvoiceAddress(); |
||
| 40 | if (!$invoiceAddress->get('name')) { |
||
| 41 | $invoiceAddress = false; |
||
| 42 | $org = $user->getOrganization(); |
||
| 43 | if ($org->isEmployee()) { |
||
| 44 | $orgUser = $org->isHiringOrganization() ? $org->getParent()->getUser() : $org->getUser(); |
||
| 45 | $invoiceAddress = $orgUser->getSettings('Orders')->getInvoiceAddress(); |
||
| 46 | if (!$invoiceAddress->get('name')) { |
||
| 47 | $invoiceAddress = false; |
||
| 48 | } |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | $entity = new InvoiceAddress(); |
||
| 53 | |||
| 54 | if ($invoiceAddress) { |
||
| 55 | $entityHydrator = new EntityHydrator(); |
||
| 56 | $settingsHydrator = new SettingsEntityHydrator(); |
||
| 57 | $data = $settingsHydrator->extract($invoiceAddress); |
||
| 58 | $entity = $entityHydrator->hydrate($data, $entity); |
||
| 59 | } |
||
| 60 | return $entity; |
||
| 61 | } |
||
| 62 | |||
| 64 | } |