1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
GroupActionTrait.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
7use Throwable;
8
10{
11 abstract public static function getCollectionElementClass(): string;
12
13 public function __call(string $name, array $args = [])
14 {
15 [$property, $operation] = $this->getPropertyAndOperationWithType($name);
16
17 if ($operation === 'get')
18 {
19 return $this->callGetMethod($property);
20 }
21
22 if ($operation === 'set')
23 {
24 return $this->callSetMethod($property, $args);
25 }
26
27 return null;
28 }
29
30 private function getPropertyAndOperationWithType(string $name): array
31 {
32 $property = lcfirst(substr($name, 3));
33 $operation = substr($name, 0, 3);
34 $isList = lcfirst(substr($property, -4)) === 'list';
35 $property = $isList ? substr($property, 0, -4) : $property;
36
37 return [$property, $operation];
38 }
39
40 private function callGetMethod(string $property): ?array
41 {
42 $getter = 'get' . $property;
43 if (!method_exists(self::getCollectionElementClass(), $getter))
44 {
45 return null;
46 }
47
48 $data = [];
49 foreach ($this as $item)
50 {
51 try
52 {
53 $data[] = $item->$getter();
54 }
55 catch (Throwable)
56 {
57
58 }
59 }
60
61 return $data;
62 }
63
64 private function callSetMethod(string $property, array $args): self
65 {
66 $setter = 'set' . $property;
67 if (!method_exists(self::getCollectionElementClass(), $setter))
68 {
69 return $this;
70 }
71
72 foreach ($this as $item)
73 {
74 try
75 {
76 $item->$setter(...$args);
77 }
78 catch (Throwable)
79 {
80
81 }
82 }
83
84 return $this;
85 }
86}
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$name
Определения menu_edit.php:35
__call(string $name, array $args=[])
Определения GroupActionTrait.php:13