| @@ 214-246 (lines=33) @@ | ||
| 211 | * @return AbstractPlugin |
|
| 212 | * @throws PluginException |
|
| 213 | */ |
|
| 214 | public function __call($name, $arguments) |
|
| 215 | { |
|
| 216 | // Search in core view helpers first |
|
| 217 | $corePlugin = 'Faulancer\Plugin\\' . ucfirst($name); |
|
| 218 | ||
| 219 | if (class_exists($corePlugin)) { |
|
| 220 | ||
| 221 | $class = new $corePlugin; |
|
| 222 | array_unshift($arguments, $this); |
|
| 223 | ||
| 224 | return call_user_func_array($class, $arguments); |
|
| 225 | ||
| 226 | } |
|
| 227 | ||
| 228 | // No core implementations found; search in custom view helpers |
|
| 229 | ||
| 230 | /** @var Config $config */ |
|
| 231 | $config = ServiceLocator::instance()->get(Config::class); |
|
| 232 | $namespace = '\\' . $config->get('namespacePrefix'); |
|
| 233 | ||
| 234 | $customPlugin = $namespace . '\Plugin\\' . ucfirst($name); |
|
| 235 | ||
| 236 | if (class_exists($customPlugin)) { |
|
| 237 | ||
| 238 | $class = new $customPlugin; |
|
| 239 | array_unshift($arguments, $this); |
|
| 240 | ||
| 241 | return call_user_func_array($class, $arguments); |
|
| 242 | ||
| 243 | } |
|
| 244 | ||
| 245 | throw new PluginException('No plugin for "' . $name . '" found.'); |
|
| 246 | } |
|
| 247 | ||
| 248 | } |
|
| @@ 262-294 (lines=33) @@ | ||
| 259 | * @return AbstractViewHelper |
|
| 260 | * @throws ViewHelperException |
|
| 261 | */ |
|
| 262 | public function __call($name, $arguments) |
|
| 263 | { |
|
| 264 | // Search in core view helpers first |
|
| 265 | $coreViewHelper = __NAMESPACE__ . '\Helper\\' . ucfirst($name); |
|
| 266 | ||
| 267 | if (class_exists($coreViewHelper)) { |
|
| 268 | ||
| 269 | $class = new $coreViewHelper; |
|
| 270 | array_unshift($arguments, $this); |
|
| 271 | ||
| 272 | return call_user_func_array($class, $arguments); |
|
| 273 | ||
| 274 | } |
|
| 275 | ||
| 276 | // No core implementations found; search in custom view helpers |
|
| 277 | ||
| 278 | /** @var Config $config */ |
|
| 279 | $config = ServiceLocator::instance()->get(Config::class); |
|
| 280 | $namespace = '\\' . $config->get('namespacePrefix'); |
|
| 281 | ||
| 282 | $customViewHelper = $namespace . '\\View\\Helper\\' . ucfirst($name); |
|
| 283 | ||
| 284 | if (class_exists($customViewHelper)) { |
|
| 285 | ||
| 286 | $class = new $customViewHelper; |
|
| 287 | array_unshift($arguments, $this); |
|
| 288 | ||
| 289 | return call_user_func_array($class, $arguments); |
|
| 290 | ||
| 291 | } |
|
| 292 | ||
| 293 | throw new ViewHelperException('No view helper for "' . $name . '" found.'); |
|
| 294 | } |
|
| 295 | ||
| 296 | /** |
|
| 297 | * Destructor |
|