Lines
100.00%
48 / 48
Functions and Methods
100.00%
6 / 6
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Organisation | 100.00% | 48 / 48 | 100.00% | 6 / 6 | 10 | 100.00% | 1 / 1 | |||
| getEntityMapping | 100.00% | 11 / 11 | 100.00% | 1 / 1 | 1 | |||||
| addConditionOrganisationId | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| addConditionOwnerId | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| addConditionScopeId | 100.00% | 14 / 14 | 100.00% | 1 / 1 | 1 | |||||
| addConditionDepartmentId | 100.00% | 8 / 8 | 100.00% | 1 / 1 | 1 | |||||
| reverseEntityMapping | 100.00% | 11 / 11 | 100.00% | 1 / 1 | 5 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsbackend\Organisation\Repository; | |
| 4 | ||
| 5 | class Organisation extends \BO\Zmsbackend\Query\Base implements \BO\Zmsbackend\Query\MappingInterface | |
| 6 | { | |
| 7 | /** | |
| 8 | * @var String TABLE mysql table reference | |
| 9 | */ | |
| 10 | const string TABLE = 'organisation'; | |
| 11 | ||
| 12 | /** | |
| 13 | * @return (\BO\Zmsbackend\Query\Builder\Expression|string)[] | |
| 14 | * | |
| 15 | */ | |
| 16 | #[\Override] | |
| 17 | public function getEntityMapping() | |
| 18 | { | |
| 19 | return [ | |
| 20 | 'contact__city' => self::expression( | |
| 21 | 'TRIM(" " FROM SUBSTRING_INDEX(`organisation`.`Anschrift`, " ", -1))' | |
| 22 | ), | |
| 23 | 'contact__street' => 'organisation.Anschrift', | |
| 24 | /* | |
| 25 | 'contact__streetNumber' => self::expression( | |
| 26 | 'TRIM("," FROM SUBSTRING_INDEX(SUBSTRING_INDEX(`organisation`.`Anschrift`, ",", 1), " ", -1))' | |
| 27 | ), | |
| 28 | 'contact__postalCode' => self::expression( | |
| 29 | 'TRIM(" " FROM SUBSTRING_INDEX(SUBSTRING_INDEX(`organisation`.`Anschrift`, " ", -2), " ", 1))' | |
| 30 | ), | |
| 31 | 'contact__region' => self::expression( | |
| 32 | 'TRIM(" " FROM SUBSTRING_INDEX(`organisation`.`Anschrift`, " ", -1))' | |
| 33 | ), | |
| 34 | */ | |
| 35 | 'contact__country' => self::expression('"Germany"'), | |
| 36 | 'contact__name' => 'organisation.Organisationsname', | |
| 37 | 'name' => 'organisation.Organisationsname', | |
| 38 | 'id' => 'organisation.OrganisationsID', | |
| 39 | 'preferences__ticketPrinterActivation' => 'organisation.kiosk_activation' | |
| 40 | ]; | |
| 41 | } | |
| 42 | ||
| 43 | public function addConditionOrganisationId($organisationId): static | |
| 44 | { | |
| 45 | $this->query->where('organisation.OrganisationsID', '=', $organisationId); | |
| 46 | return $this; | |
| 47 | } | |
| 48 | ||
| 49 | public function addConditionOwnerId($ownerId): static | |
| 50 | { | |
| 51 | $this->query->where('organisation.KundenID', '=', $ownerId); | |
| 52 | return $this; | |
| 53 | } | |
| 54 | ||
| 55 | public function addConditionScopeId($scopeId): static | |
| 56 | { | |
| 57 | $this->leftJoin( | |
| 58 | new \BO\Zmsbackend\Query\Alias('behoerde', 'department'), | |
| 59 | 'department.OrganisationsID', | |
| 60 | '=', | |
| 61 | 'organisation.OrganisationsID' | |
| 62 | ); | |
| 63 | $this->leftJoin( | |
| 64 | new \BO\Zmsbackend\Query\Alias('standort', 'scope'), | |
| 65 | 'scope.BehoerdenID', | |
| 66 | '=', | |
| 67 | 'department.BehoerdenID' | |
| 68 | ); | |
| 69 | $this->query->where('scope.StandortID', '=', $scopeId); | |
| 70 | return $this; | |
| 71 | } | |
| 72 | ||
| 73 | public function addConditionDepartmentId($departmentId): static | |
| 74 | { | |
| 75 | $this->leftJoin( | |
| 76 | new \BO\Zmsbackend\Query\Alias('behoerde', 'department'), | |
| 77 | 'department.OrganisationsID', | |
| 78 | '=', | |
| 79 | 'organisation.OrganisationsID' | |
| 80 | ); | |
| 81 | $this->query->where('department.BehoerdenID', '=', $departmentId); | |
| 82 | return $this; | |
| 83 | } | |
| 84 | ||
| 85 | /** | |
| 86 | * @return (int|mixed|string)[] | |
| 87 | * | |
| 88 | */ | |
| 89 | public function reverseEntityMapping(\BO\Zmsentities\Organisation $entity, $parentId = null): array | |
| 90 | { | |
| 91 | $data = array(); | |
| 92 | if (null !== $parentId) { | |
| 93 | $data['KundenID'] = $parentId; | |
| 94 | } | |
| 95 | $data['Organisationsname'] = $entity->name; | |
| 96 | $data['InfoBezirkID'] = 14; | |
| 97 | $data['Anschrift'] = (isset($entity->contact['street'])) ? $entity->contact['street'] : ''; | |
| 98 | $data['kiosk_activation'] = ($entity->getPreference('ticketPrinterActivation')) ? 1 : 0; | |
| 99 | $data = array_filter($data, function ($value) { | |
| 100 | return ($value !== null && $value !== false); | |
| 101 | }); | |
| 102 | return $data; | |
| 103 | } | |
| 104 | } |