1 | <?php |
||||||
2 | |||||||
3 | namespace Nip\View\Extensions\Helpers; |
||||||
4 | |||||||
5 | use Nip\View; |
||||||
6 | use Nip\View\Extensions\AbstractExtension; |
||||||
7 | use Nip\View\Helpers\HelpersCollection; |
||||||
8 | use Nip\View\Traits\HasMethodsTrait; |
||||||
9 | use Nip\View\Traits\MethodsOverloadingTrait; |
||||||
10 | use Nip\View\ViewInterface; |
||||||
11 | |||||||
12 | /** |
||||||
13 | * Class HelpersExtension |
||||||
14 | * @package Nip\View\Extensions\Helpers |
||||||
15 | */ |
||||||
16 | class HelpersExtension extends AbstractExtension |
||||||
17 | { |
||||||
18 | |||||||
19 | /** |
||||||
20 | * @param ViewInterface|MethodsOverloadingTrait|HasMethodsTrait|View $view |
||||||
21 | * @return void |
||||||
22 | */ |
||||||
23 | 6 | public function register(ViewInterface $view) |
|||||
24 | { |
||||||
25 | 6 | $view->getCallPipelineBuilder()->add(new HelpersPipelineStage()); |
|||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
26 | 6 | HelpersCollection::getInstance()->setEngine($view); |
|||||
27 | |||||||
28 | 6 | $view->addMethod('getHelper', function ($name) { |
|||||
0 ignored issues
–
show
The method
addMethod() does not exist on Nip\View\ViewInterface . Since it exists in all sub-types, consider adding an abstract or default implementation to Nip\View\ViewInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
29 | 1 | return HelpersCollection::getInstance()->getHelper($name); |
|||||
30 | 6 | }); |
|||||
31 | |||||||
32 | 6 | $view->addMethod('hasHelper', function ($name) { |
|||||
33 | 1 | return HelpersCollection::getInstance()->hasHelper($name); |
|||||
34 | 6 | }); |
|||||
35 | 6 | } |
|||||
36 | } |
||||||
37 |