1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | namespace Nip\View\ResolveTemplatePath; |
||||
6 | |||||
7 | use League\Plates\Exception\TemplateNotFound; |
||||
8 | use League\Plates\Template\Name; |
||||
9 | use League\Plates\Template\ResolveTemplatePath; |
||||
10 | |||||
11 | /** |
||||
12 | * Trait HasViewFinder. |
||||
13 | */ |
||||
14 | trait HasViewFinder |
||||
15 | { |
||||
16 | /** |
||||
17 | * Adds a path where templates are stored. |
||||
18 | * |
||||
19 | * @param string $path A path where to look for templates |
||||
20 | * @param string $namespace A path namespace |
||||
21 | * |
||||
22 | * @return void |
||||
23 | */ |
||||
24 | public function addPath($path, $namespace = ThemeFolderResolveTemplatePath::MAIN_NAMESPACE) |
||||
25 | { |
||||
26 | $this->getResolveTemplatePath()->addPath($path, $namespace); |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
27 | } |
||||
28 | |||||
29 | /** |
||||
30 | * Prepends a path where templates are stored. |
||||
31 | * |
||||
32 | * @param string $path A path where to look for templates |
||||
33 | * @param string $namespace A path namespace |
||||
34 | * |
||||
35 | * @return void |
||||
36 | */ |
||||
37 | public function prependPath($path, $namespace = ThemeFolderResolveTemplatePath::MAIN_NAMESPACE) |
||||
38 | { |
||||
39 | $this->getResolveTemplatePath()->prependPath($path, $namespace); |
||||
40 | } |
||||
41 | |||||
42 | public function existPath($view): bool |
||||
43 | { |
||||
44 | try { |
||||
45 | $name = new Name($this, $view); |
||||
0 ignored issues
–
show
$this of type Nip\View\ResolveTemplatePath\HasViewFinder is incompatible with the type League\Plates\Engine expected by parameter $engine of League\Plates\Template\Name::__construct() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
46 | ($this->getResolveTemplatePath())($name); |
||||
47 | |||||
48 | return true; |
||||
49 | } catch (TemplateNotFound $exception) { |
||||
50 | return false; |
||||
51 | } |
||||
52 | } |
||||
53 | |||||
54 | /** |
||||
55 | * @deprecated use getResolveTemplatePath |
||||
56 | */ |
||||
57 | public function getFinder(): ResolveTemplatePath |
||||
58 | { |
||||
59 | return $this->getResolveTemplatePath(); |
||||
60 | } |
||||
61 | } |
||||
62 |