1 | <?php |
||
37 | 1 | class Slug extends Forms\Controls\TextInput |
|
38 | { |
||
39 | /** |
||
40 | * @var string|NULL |
||
41 | */ |
||
42 | private $templateFile; |
||
43 | |||
44 | /** |
||
45 | * @var UI\ITemplate |
||
46 | */ |
||
47 | private $template; |
||
48 | |||
49 | /** |
||
50 | * @var UI\ITemplateFactory |
||
51 | */ |
||
52 | private $templateFactory; |
||
53 | |||
54 | /** |
||
55 | * @var Forms\Controls\BaseControl[] |
||
56 | */ |
||
57 | private $fields = []; |
||
58 | |||
59 | /** |
||
60 | * Toggle box selector |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | private $toggleBox = '.ipub-slug-box'; |
||
65 | |||
66 | /** |
||
67 | * @var bool |
||
68 | */ |
||
69 | private static $registered = FALSE; |
||
70 | |||
71 | /** |
||
72 | * Enable or disable one time auto updating slug field from watched fields |
||
73 | * |
||
74 | * @var bool |
||
75 | */ |
||
76 | private $onetimeAutoUpdate = TRUE; |
||
77 | |||
78 | /** |
||
79 | * Enable or disable updating field when editing watched field |
||
80 | * |
||
81 | * @var bool |
||
82 | */ |
||
83 | private $forceEditUpdate = FALSE; |
||
84 | |||
85 | /** |
||
86 | * @param UI\ITemplateFactory $templateFactory |
||
87 | * @param string|NULL $label |
||
88 | * @param int|NULL $maxLength |
||
89 | */ |
||
90 | public function __construct(UI\ITemplateFactory $templateFactory, string $label = NULL, int $maxLength = NULL) |
||
96 | |||
97 | /** |
||
98 | * Add filed from which slug will be created |
||
99 | * |
||
100 | * @param Forms\Controls\BaseControl $field |
||
101 | * |
||
102 | * @return self |
||
103 | */ |
||
104 | public function addField(Forms\Controls\BaseControl $field) : self |
||
111 | |||
112 | /** |
||
113 | * @return self |
||
114 | */ |
||
115 | public function disableOneTimeUpdate() : self |
||
121 | |||
122 | /** |
||
123 | * @return self |
||
124 | */ |
||
125 | public function enableOneTimeUpdate() : self |
||
131 | |||
132 | /** |
||
133 | * @return self |
||
134 | */ |
||
135 | public function disableForceEditUpdate() : self |
||
141 | |||
142 | /** |
||
143 | * @return self |
||
144 | */ |
||
145 | public function enableForceEditUpdate() : self |
||
151 | |||
152 | /** |
||
153 | * Generates control's HTML element |
||
154 | * |
||
155 | * @return Utils\Html |
||
156 | */ |
||
157 | public function getControl() : Utils\Html |
||
194 | |||
195 | /** |
||
196 | * Change default control template path |
||
197 | * |
||
198 | * @param string $templateFile |
||
199 | * |
||
200 | * @return void |
||
201 | * |
||
202 | * @throws Exceptions\FileNotFoundException |
||
203 | */ |
||
204 | public function setTemplateFile(string $templateFile) : void |
||
220 | |||
221 | /** |
||
222 | * @return string |
||
223 | */ |
||
224 | private function getTemplateFile() : string |
||
228 | |||
229 | /** |
||
230 | * @return UI\ITemplate|Bridges\ApplicationLatte\Template |
||
231 | */ |
||
232 | private function getTemplate() : UI\ITemplate |
||
241 | |||
242 | /** |
||
243 | * @param UI\ITemplateFactory $templateFactory |
||
244 | * @param string $method |
||
245 | * |
||
246 | * @return void |
||
247 | */ |
||
248 | public static function register(UI\ITemplateFactory $templateFactory, $method = 'addSlug') : void |
||
268 | } |
||
269 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: