Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
21 / 21 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
OwnerList | |
100.00% |
21 / 21 |
|
100.00% |
3 / 3 |
10 | |
100.00% |
1 / 1 |
getOrganisationsByOwnerId | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
4 | |||
toDepartmentListByOrganisationName | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
withAccess | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | namespace BO\Zmsentities\Collection; |
4 | |
5 | class OwnerList extends Base |
6 | { |
7 | const ENTITY_CLASS = '\BO\Zmsentities\Owner'; |
8 | |
9 | public function getOrganisationsByOwnerId($entityId) |
10 | { |
11 | $organisationList = new OrganisationList(); |
12 | foreach ($this as $entity) { |
13 | if ($entityId == $entity->id) { |
14 | foreach ($entity->organisations as $organisation) { |
15 | $organisation = new \BO\Zmsentities\Organisation($organisation); |
16 | $organisationList->addEntity($organisation); |
17 | } |
18 | } |
19 | } |
20 | return $organisationList->sortByName(); |
21 | } |
22 | |
23 | public function toDepartmentListByOrganisationName() |
24 | { |
25 | $list = array(); |
26 | foreach ($this as $entity) { |
27 | $organisationList = $this->getOrganisationsByOwnerId($entity->id); |
28 | foreach ($organisationList as $organisation) { |
29 | $list[$entity->name][$organisation->name] = $organisation->departments; |
30 | } |
31 | } |
32 | return $list; |
33 | } |
34 | |
35 | public function withAccess(\BO\Zmsentities\Useraccount $useraccount) |
36 | { |
37 | $list = new static(); |
38 | foreach ($this as $owner) { |
39 | $owner = clone $owner; |
40 | $owner->organisations = $owner->getOrganisationList()->withAccess($useraccount); |
41 | $owner->organisations->sortByName(); |
42 | if ($owner->hasAccess($useraccount)) { |
43 | $list[] = $owner; |
44 | } |
45 | } |
46 | return $list; |
47 | } |
48 | } |