Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
type.php
1<?php
2namespace Bitrix\Landing\Node;
3
4class Type
5{
6 const COMPONENT = 'component';
7 const MEDIA = 'embed';
8 const ICON = 'icon';
9 const IMAGE = 'img';
10 const LINK = 'link';
11 const MAP = 'map';
12 const TEXT = 'text';
13 const STYLE_IMAGE = 'styleimg';
14
15 protected static $classes = [];
16
22 public static function getClassName(string $type): string
23 {
24 $type = mb_strtolower($type);
25
26 if ($type === '' || $type === 'type')
27 {
28 throw new \Bitrix\Main\ArgumentTypeException(
29 'Invalid node type'
30 );
31 }
32
33 if (isset(self::$classes[$type]))
34 {
35 return self::$classes[$type];
36 }
37
38 $class = __NAMESPACE__ . '\\' . $type;
39
40 // check custom classes
41 $event = new \Bitrix\Main\Event(
42 'landing',
43 'onGetNodeClass',
44 [
45 'type' => $type
46 ]
47 );
48 $event->send();
50 foreach ($event->getResults() as $result)
51 {
52 if ($result->getType() != \Bitrix\Main\EventResult::ERROR)
53 {
54 if (
55 ($modified = $result->getModified()) &&
56 isset($modified['class']) &&
57 is_subclass_of($modified['class'], '\\Bitrix\\Landing\\Node')
58 )
59 {
60 $class = $modified['class'];
61 }
62 }
63 }
64
65 self::$classes[$type] = $class;
66
67 return self::$classes[$type];
68 }
69}