|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Nip\View\Extensions\Helpers; |
|
6
|
|
|
|
|
7
|
|
|
use Nip\View\Helpers\DoctypeHelper; |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* Trait HasHelpersTrait. |
|
11
|
|
|
* |
|
12
|
|
|
* @method hasHelper($name) |
|
13
|
|
|
* @method getHelper($name) |
|
14
|
|
|
* @method DoctypeHelper Doctype() |
|
15
|
|
|
* @method Helpers\View\Breadcrumbs Breadcrumbs() |
|
16
|
|
|
* @method Helpers\View\Flash Flash() |
|
17
|
|
|
* @method Helpers\View\FacebookMeta FacebookMeta() |
|
18
|
|
|
* @method Helpers\View\GoogleAnalytics GoogleAnalytics() |
|
19
|
|
|
* @method Helpers\View\HTML HTML() |
|
20
|
|
|
* @method Helpers\View\Messages Messages() |
|
21
|
|
|
* @method Helpers\View\Meta Meta() |
|
22
|
|
|
* @method Helpers\View\Paginator Paginator() |
|
23
|
|
|
* @method Helpers\View\Scripts Scripts() |
|
24
|
|
|
* @method Helpers\View\Stylesheets Stylesheets() |
|
25
|
|
|
* @method Helpers\View\TinyMCE TinyMCE() |
|
26
|
|
|
* @method Helpers\View\Url Url() |
|
27
|
|
|
* @method Helpers\View\GoogleDFP GoogleDFP() |
|
28
|
|
|
*/ |
|
29
|
|
|
trait HasHelpersTrait |
|
30
|
|
|
{ |
|
31
|
|
|
public function addHelpersExtension() |
|
32
|
|
|
{ |
|
33
|
11 |
|
$this->loadExtension(new HelpersExtension()); |
|
|
|
|
|
|
34
|
|
|
} |
|
35
|
11 |
|
|
|
36
|
11 |
|
/** |
|
37
|
|
|
* {@inheritDoc} |
|
38
|
|
|
*/ |
|
39
|
|
|
public function getFunction($name) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->initFunctionHelper($name); |
|
42
|
|
|
|
|
43
|
|
|
return parent::getFunction($name); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @return mixed |
|
48
|
|
|
*/ |
|
49
|
|
|
protected function initFunctionHelper($name) |
|
50
|
|
|
{ |
|
51
|
|
|
if ($this->doesFunctionExist($name)) { |
|
|
|
|
|
|
52
|
|
|
return; |
|
53
|
|
|
} |
|
54
|
|
|
if (false === $this->hasHelper($name)) { |
|
55
|
|
|
return; |
|
56
|
|
|
} |
|
57
|
|
|
$this->registerFunction($name, function () use ($name) { |
|
|
|
|
|
|
58
|
|
|
return $this->getHelper($name); |
|
59
|
|
|
}); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|