Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
30 / 30 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| Link | |
100.00% |
30 / 30 |
|
100.00% |
4 / 4 |
8 | |
100.00% |
1 / 1 |
| getEntityMapping | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
| addConditionLinkId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| addConditionDepartmentId | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| reverseEntityMapping | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
5 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Zmsdb\Query; |
| 4 | |
| 5 | class Link extends Base |
| 6 | { |
| 7 | /** |
| 8 | * @var String TABLE mysql table reference |
| 9 | */ |
| 10 | const TABLE = 'kundenlinks'; |
| 11 | |
| 12 | /** |
| 13 | * No resolving required here |
| 14 | */ |
| 15 | protected $resolveLevel = 0; |
| 16 | |
| 17 | public function getEntityMapping() |
| 18 | { |
| 19 | return [ |
| 20 | 'id' => 'link.linkid', |
| 21 | 'name' => 'link.beschreibung', |
| 22 | 'url' => 'link.link', |
| 23 | 'target' => 'link.neuerFrame', |
| 24 | 'public' => 'link.oeffentlich', |
| 25 | 'organisation' => 'link.organisationsid' |
| 26 | ]; |
| 27 | } |
| 28 | |
| 29 | public function addConditionLinkId($linkId) |
| 30 | { |
| 31 | $this->query->where('link.linkid', '=', $linkId); |
| 32 | return $this; |
| 33 | } |
| 34 | |
| 35 | public function addConditionDepartmentId($departmentId) |
| 36 | { |
| 37 | $this->leftJoin( |
| 38 | new Alias('behoerde', 'link_department'), |
| 39 | 'link_department.OrganisationsID', |
| 40 | '=', |
| 41 | 'link.organisationsid' |
| 42 | ); |
| 43 | $this->query->where('link_department.BehoerdenID', '=', $departmentId); |
| 44 | $this->query->orWhere('link.behoerdenid', '=', $departmentId); |
| 45 | return $this; |
| 46 | } |
| 47 | |
| 48 | public function reverseEntityMapping(\BO\Zmsentities\Link $entity, $departmentId) |
| 49 | { |
| 50 | $data = array(); |
| 51 | $data['behoerdenid'] = ($entity->organisation) ? 0 : $departmentId; |
| 52 | $data['organisationsid'] = $entity->organisation; |
| 53 | $data['beschreibung'] = $entity->name; |
| 54 | $data['link'] = $entity->url; |
| 55 | $data['neuerFrame'] = ($entity->target) ? 1 : 0; |
| 56 | $data['oeffentlich'] = ($entity->public) ? 1 : 0; |
| 57 | |
| 58 | $data = array_filter($data, function ($value) { |
| 59 | return ($value !== null && $value !== false); |
| 60 | }); |
| 61 | return $data; |
| 62 | } |
| 63 | } |