1 | <?php |
||
40 | 1 | class Control extends Application\UI\Control |
|
41 | { |
||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | private $templateFile; |
||
46 | |||
47 | /** |
||
48 | * @var Storage\IStorage |
||
49 | */ |
||
50 | private $storage; |
||
51 | |||
52 | /** |
||
53 | * @var Localization\ITranslator |
||
54 | */ |
||
55 | private $translator; |
||
56 | |||
57 | /** |
||
58 | * @var bool |
||
59 | */ |
||
60 | private $useTitle = FALSE; |
||
61 | |||
62 | /** |
||
63 | * @var bool |
||
64 | */ |
||
65 | private $useOverlay = FALSE; |
||
66 | |||
67 | /** |
||
68 | * @param Localization\ITranslator $translator |
||
69 | */ |
||
70 | public function injectTranslator(Localization\ITranslator $translator = NULL) |
||
74 | |||
75 | /** |
||
76 | * @param NULL|string $templateFile |
||
77 | * @param Storage\IStorage $storage |
||
78 | * |
||
79 | * @throws Exceptions\FileNotFoundException |
||
80 | */ |
||
81 | public function __construct( |
||
93 | |||
94 | /** |
||
95 | * @param \Nette\ComponentModel\IComponent |
||
96 | */ |
||
97 | public function attached($presenter) |
||
103 | |||
104 | /** |
||
105 | * @return void |
||
106 | */ |
||
107 | public function enableTitle() |
||
111 | |||
112 | /** |
||
113 | * @return void |
||
114 | */ |
||
115 | public function disableTitle() |
||
119 | |||
120 | /** |
||
121 | * @return void |
||
122 | */ |
||
123 | public function enableOverlay() |
||
127 | |||
128 | /** |
||
129 | * @return void |
||
130 | */ |
||
131 | public function disableOverlay() |
||
135 | |||
136 | /** |
||
137 | * Prepare component for rendering |
||
138 | */ |
||
139 | public function beforeRender() |
||
162 | |||
163 | /** |
||
164 | * Render control |
||
165 | */ |
||
166 | public function render() |
||
179 | |||
180 | /** |
||
181 | * Change default control template path |
||
182 | * |
||
183 | * @param string $templateFile |
||
184 | * |
||
185 | * @return void |
||
186 | * |
||
187 | * @throws Exceptions\FileNotFoundException |
||
188 | */ |
||
189 | public function setTemplateFile($templateFile) |
||
190 | { |
||
191 | // Check if template file exists... |
||
192 | 1 | if (!is_file($templateFile)) { |
|
193 | // Get component actual dir |
||
194 | 1 | $dir = dirname($this->getReflection()->getFileName()); |
|
195 | |||
196 | 1 | $templateName = preg_replace('/.latte/', '', $templateFile); |
|
197 | |||
198 | // ...check if extension template is used |
||
199 | 1 | if (is_file($dir . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . $templateName . DIRECTORY_SEPARATOR . 'default.latte')) { |
|
200 | 1 | $templateFile = $dir . DIRECTORY_SEPARATOR . 'template' . DIRECTORY_SEPARATOR . $templateName . DIRECTORY_SEPARATOR . 'default.latte'; |
|
201 | |||
202 | } else { |
||
203 | // ...if not throw exception |
||
204 | 1 | throw new Exceptions\FileNotFoundException(sprintf('Template file "%s" was not found.', $templateFile)); |
|
205 | } |
||
206 | } |
||
207 | |||
208 | 1 | $this->templateFile = $templateFile; |
|
209 | 1 | } |
|
210 | |||
211 | /** |
||
212 | * @param Localization\ITranslator $translator |
||
213 | * |
||
214 | * @return void |
||
215 | */ |
||
216 | public function setTranslator(Localization\ITranslator $translator) |
||
220 | |||
221 | /** |
||
222 | * @return Localization\ITranslator|null |
||
223 | */ |
||
224 | public function getTranslator() |
||
232 | } |
||
233 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: