Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
renderer.php
1<?php
2
4
7
8abstract class Renderer
9{
10 const JS_TYPE_UNKNOWN = 'unknown';
11
12 protected $name;
14 protected $sourceUri;
16 protected $options;
17
18 public function __construct($name, Uri $sourceUri, array $options = [])
19 {
20 $this->name = $name;
21 $this->sourceUri = $sourceUri;
22 $this->options = $options;
23 }
24
25 public function getOption($name, $defaultValue = null)
26 {
27 $value = $this->getByPath($this->options, $name, $defaultValue);
28 if ($value instanceof \Closure)
29 {
30 return $value();
31 }
32
33 return $value;
34 }
35
45 private function getByPath($array, $path, $defaultValue = null)
46 {
47 if(!is_array($array) && !$array instanceof \ArrayAccess)
48 {
49 throw new ArgumentException("\$array is not array or don't implement ArrayAccess");
50 }
51
52 $pathItems = explode('.', $path);
53
54 $lastArray = $array;
55 foreach($pathItems as $pathItem)
56 {
57 if(!is_array($lastArray) && !$lastArray instanceof \ArrayAccess)
58 {
59 return $defaultValue;
60 }
61
62 if(!isset($lastArray[$pathItem]))
63 {
64 return $defaultValue;
65 }
66
67 $lastArray = $lastArray[$pathItem];
68 }
69
70 return $lastArray;
71 }
72
73 public static function getAllowedContentTypes()
74 {
75 return [];
76 }
77
78 public static function getJsType()
79 {
81 }
82
83 public static function getSizeRestriction()
84 {
85 return null;
86 }
87
88 abstract public function render();
89
90 public function getData()
91 {
92 return null;
93 }
94}
__construct($name, Uri $sourceUri, array $options=[])
Definition renderer.php:18
getOption($name, $defaultValue=null)
Definition renderer.php:25