Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Departments.php
1<?php
2
4
6
13{
14 public function __construct(int ...$departmentIds)
15 {
16 parent::__construct();
17
18 foreach ($departmentIds as $departmentId)
19 {
20 $this[] = new Department($departmentId);
21 }
22 }
23
24 public function filterExist(): self
25 {
26 $filtered = new static();
27
28 foreach ($this as $department)
29 {
30 if ($department->isExist())
31 {
32 $filtered[] = $department;
33 }
34 }
35
36 return $filtered;
37 }
38
39 public function getDeepest(): self
40 {
41 $maxDepth = 0;
42
43 foreach ($this as $department)
44 {
45 $maxDepth = max($maxDepth, $department->getDepth());
46 }
47
48 $newCollection = new static();
49
50 foreach ($this as $department)
51 {
52 if ($department->getDepth() === $maxDepth)
53 {
54 $newCollection[] = $department;
55 }
56 }
57
58 return $newCollection;
59 }
60
61 public static function getRestEntityName(): string
62 {
63 return 'departments';
64 }
65}