Lines
100.00%
50 / 50
Functions and Methods
100.00%
7 / 7
Classes and Traits
100.00%
1 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Provider | 100.00% | 50 / 50 | 100.00% | 7 / 7 | 12 | 100.00% | 1 / 1 | |||
| getEntityMapping | 100.00% | 18 / 18 | 100.00% | 1 / 1 | 2 | |||||
| addConditionIsAssigned | 100.00% | 11 / 11 | 100.00% | 1 / 1 | 3 | |||||
| addConditionProviderId | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| addConditionProviderIdList | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| addConditionProviderSource | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | |||||
| addConditionRequestCsv | 100.00% | 12 / 12 | 100.00% | 1 / 1 | 1 | |||||
| postProcess | 100.00% | 3 / 3 | 100.00% | 1 / 1 | 3 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsbackend\Provider\Repository; | |
| 4 | ||
| 5 | class Provider extends \BO\Zmsbackend\Query\Base | |
| 6 | { | |
| 7 | const string TABLE = 'provider'; | |
| 8 | ||
| 9 | /** | |
| 10 | * @psalm-api | |
| 11 | * | |
| 12 | * @return (\BO\Zmsbackend\Query\Builder\Expression|string)[] | |
| 13 | * | |
| 14 | */ | |
| 15 | public function getEntityMapping(): array | |
| 16 | { | |
| 17 | $mapping = [ | |
| 18 | 'contact__city' => 'provider.contact__city', | |
| 19 | 'contact__country' => self::expression('"Germany"'), | |
| 20 | 'contact__name' => 'provider.name', | |
| 21 | 'contact__postalCode' => 'provider.contact__postalCode', | |
| 22 | 'contact__region' => 'provider.contact__region', | |
| 23 | 'contact__street' => 'provider.contact__street', | |
| 24 | 'contact__streetNumber' => 'provider.contact__streetNumber', | |
| 25 | 'id' => 'provider.id', | |
| 26 | 'link' => 'provider.link', | |
| 27 | 'name' => 'provider.name', | |
| 28 | 'displayName' => 'provider.display_name', | |
| 29 | 'source' => 'provider.source', | |
| 30 | 'parent_id' => 'provider.parent_id' | |
| 31 | ]; | |
| 32 | if ($this->getResolveLevel() > 0) { | |
| 33 | $mapping['data'] = 'provider.data'; | |
| 34 | } | |
| 35 | return $mapping; | |
| 36 | } | |
| 37 | ||
| 38 | public function addConditionIsAssigned($isAssigned): static | |
| 39 | { | |
| 40 | $this->leftJoin( | |
| 41 | new \BO\Zmsbackend\Query\Alias(\BO\Zmsbackend\Query\Scope::TABLE, 'assignedscope'), | |
| 42 | 'provider.id', | |
| 43 | '=', | |
| 44 | 'assignedscope.InfoDienstleisterID' | |
| 45 | ); | |
| 46 | if (true === $isAssigned) { | |
| 47 | $this->query->where('assignedscope.InfoDienstleisterID', 'IS NOT', null); | |
| 48 | } elseif (false === $isAssigned) { | |
| 49 | $this->query->where('assignedscope.InfoDienstleisterID', 'IS', null); | |
| 50 | } | |
| 51 | return $this; | |
| 52 | } | |
| 53 | ||
| 54 | public function addConditionProviderId($providerId): static | |
| 55 | { | |
| 56 | $this->query->where('provider.id', '=', $providerId); | |
| 57 | return $this; | |
| 58 | } | |
| 59 | ||
| 60 | public function addConditionProviderIdList(array $providerIds): self | |
| 61 | { | |
| 62 | $this->query->where('provider.id', 'IN', array_map('intval', $providerIds)); | |
| 63 | ||
| 64 | return $this; | |
| 65 | } | |
| 66 | ||
| 67 | public function addConditionProviderSource($source): static | |
| 68 | { | |
| 69 | $this->query->where('provider.source', '=', $source); | |
| 70 | return $this; | |
| 71 | } | |
| 72 | ||
| 73 | /** | |
| 74 | * @todo find calls and implement "sourceName"-parameter to remove default value | |
| 75 | */ | |
| 76 | public function addConditionRequestCsv($requestIdCsv, $sourceName = 'dldb'): void | |
| 77 | { | |
| 78 | $requestIdList = explode(',', $requestIdCsv); | |
| 79 | $this->leftJoin( | |
| 80 | new \BO\Zmsbackend\Query\Alias("request_provider", 'xprovider'), | |
| 81 | 'provider.id', | |
| 82 | '=', | |
| 83 | 'xprovider.provider__id' | |
| 84 | ); | |
| 85 | $this->query->where(function (\BO\Zmsbackend\Query\Builder\ConditionBuilder $query) use ($requestIdList, $sourceName) { | |
| 86 | $query->andWith('xprovider.request__id', 'IN', $requestIdList); | |
| 87 | $query->andWith('xprovider.bookable', '=', 1); | |
| 88 | $query->andWith('xprovider.source', '=', $sourceName); | |
| 89 | }); | |
| 90 | } | |
| 91 | ||
| 92 | #[\Override] | |
| 93 | public function postProcess($data) | |
| 94 | { | |
| 95 | if (isset($data[$this->getPrefixed('data')]) && $data[$this->getPrefixed('data')]) { | |
| 96 | $data[$this->getPrefixed('data')] = json_decode($data[$this->getPrefixed('data')], true); | |
| 97 | } | |
| 98 | return $data; | |
| 99 | } | |
| 100 | } |