1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
event.php
См. документацию.
1<?php
2namespace Bitrix\Catalog\Model;
3
4use Bitrix\Main,
5 Bitrix\Main\Localization\Loc,
6 Bitrix\Catalog;
7
8Loc::loadMessages(__FILE__);
9
10class Event extends Main\Event
11{
13 protected $entity = null;
14
15 protected static $catalogHandlerExist = [];
16
17 private static $keys = ['fields', 'external_fields', 'actions'];
18
19 public function __construct(Entity $entity, string $type, array $parameters = [])
20 {
21 $this->entity = $entity;
22
23 parent::__construct('catalog', self::makeEventName(get_class($this->entity), $type), $parameters);
24 }
25
33 public function getErrors(Main\Result $result): bool
34 {
35 $hasErrors = false;
36
38 foreach($this->getResults() as $eventResult)
39 {
40 if ($eventResult->getType() === Main\Entity\EventResult::ERROR)
41 {
42 $hasErrors = true;
43 $result->addErrors($eventResult->getErrors());
44 }
45 }
46 return $hasErrors;
47 }
48
55 public function mergeData(array &$data): void
56 {
58 foreach($this->getResults() as $eventResult)
59 {
60 $removed = $eventResult->getUnset();
61 foreach (self::$keys as $index)
62 {
63 if (empty($removed[$index]))
64 continue;
65 foreach ($removed[$index] as $key)
66 unset($data[$index][$key]);
67 unset($key);
68 }
69 unset($removed);
70 $modified = $eventResult->getModified();
71 foreach (self::$keys as $index)
72 {
73 if (empty($modified[$index]))
74 continue;
75 $data[$index] = array_merge($data[$index], $modified[$index]);
76 }
77 unset($modified);
78 }
79 }
80
88 public static function existEventHandlers(Entity $entity, string $eventName): bool
89 {
90 return static::existEventHandlersById(self::makeEventName(get_class($entity), $eventName));
91 }
92
98 public static function makeEventName(string $class, string $eventName): string
99 {
100 return $class.'::'.$eventName;
101 }
102
109 public static function existEventHandlersById(string $id): bool
110 {
111 if (!isset(self::$catalogHandlerExist[$id]))
112 {
114 $eventsList = $eventManager->findEventHandlers(
115 'catalog', $id
116 );
117 self::$catalogHandlerExist[$id] = !empty($eventsList);
118 unset($eventsList, $eventManager);
119 }
120 return self::$catalogHandlerExist[$id];
121 }
122}
static $catalogHandlerExist
Определения event.php:15
__construct(Entity $entity, string $type, array $parameters=[])
Определения event.php:19
static makeEventName(string $class, string $eventName)
Определения event.php:98
static existEventHandlersById(string $id)
Определения event.php:109
static existEventHandlers(Entity $entity, string $eventName)
Определения event.php:88
Определения event.php:5
$type
Определения event.php:7
$parameters
Определения event.php:8
static getInstance()
Определения eventmanager.php:31
$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
$result
Определения get_property_values.php:14
Определения ufield.php:9
getErrors()
Определения errorableimplementation.php:34
Определения buffer.php:3
if(empty($signedUserToken)) $key
Определения quickway.php:257
$eventManager
Определения include.php:412