@@ 15-41 (lines=27) @@ | ||
12 | * @package Faulancer\View\Helper |
|
13 | * @author Florian Knapp <[email protected]> |
|
14 | */ |
|
15 | class RenderView extends AbstractViewHelper |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * Render a subview |
|
20 | * |
|
21 | * @param string $template |
|
22 | * @param array $variables |
|
23 | * @return string |
|
24 | * |
|
25 | * @throws FileNotFoundException |
|
26 | * @throws ServiceNotFoundException |
|
27 | */ |
|
28 | public function __invoke(string $template = '', array $variables = []) |
|
29 | { |
|
30 | $subview = new ViewController(); |
|
31 | ||
32 | if (!empty($this->view->getTemplatePath())) { |
|
33 | $subview->setTemplatePath($this->view->getTemplatePath()); |
|
34 | } |
|
35 | ||
36 | $subview->setTemplate( $template ); |
|
37 | $subview->setVariables( $variables ); |
|
38 | return $subview->render(); |
|
39 | } |
|
40 | ||
41 | } |
@@ 15-38 (lines=24) @@ | ||
12 | * @package Faulancer\View\Helper |
|
13 | * @author Florian Knapp <[email protected]> |
|
14 | */ |
|
15 | class ParentTemplate extends AbstractViewHelper |
|
16 | { |
|
17 | ||
18 | /** |
|
19 | * Define the parent template |
|
20 | * |
|
21 | * @param string $template |
|
22 | * |
|
23 | * @throws FileNotFoundException |
|
24 | */ |
|
25 | public function __invoke(string $template = '') |
|
26 | { |
|
27 | $viewParent = new ViewController(); |
|
28 | ||
29 | if (!empty($this->getView()->getTemplatePath())) { |
|
30 | $viewParent->setTemplatePath($this->view->getTemplatePath()); |
|
31 | } |
|
32 | ||
33 | $viewParent->setTemplate($template); |
|
34 | $this->view->setParentTemplate($viewParent); |
|
35 | } |
|
36 | ||
37 | } |