[BUGFIX] Revert BackendActionController in favor of BackendView
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / View / BackendTemplateView.php
1 <?php
2 namespace TYPO3\CMS\Backend\View;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Template\ModuleTemplate;
18 use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
19 use TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext;
20 use TYPO3\CMS\Fluid\View\TemplateView;
21
22 /**
23 * Decorates the main template view. Should be used as view if you want Fluid Templating in a backend moduel
24 *
25 * @api
26 */
27 class BackendTemplateView implements ViewInterface {
28
29 /**
30 * @var ModuleTemplate
31 */
32 protected $moduleTemplate;
33
34 /**
35 * @var TemplateView
36 */
37 protected $templateView;
38
39 /**
40 * @param ModuleTemplate $moduleTemplate
41 */
42 public function injectModuleTemplate(ModuleTemplate $moduleTemplate) {
43 $this->moduleTemplate = $moduleTemplate;
44 }
45
46 /**
47 * @param TemplateView $templateView
48 */
49 public function injectTemplateView(TemplateView $templateView) {
50 $this->templateView = $templateView;
51 }
52
53 /**
54 * @return ModuleTemplate
55 */
56 public function getModuleTemplate() {
57 return $this->moduleTemplate;
58 }
59
60 /**
61 * Loads the template source and render the template.
62 * If "layoutName" is set in a PostParseFacet callback, it will render the file with the given layout.
63 *
64 * Additionally amends the rendered template with a module template "frame"
65 *
66 * @param string $actionName If set, the view of the specified action will be rendered instead. Default is the action specified in the Request object
67 * @return string Rendered Template
68 * @api
69 */
70 public function render($actionName = NULL) {
71 $actionViewContent = $this->templateView->render($actionName);
72 $this->moduleTemplate->setContent($actionViewContent);
73 return $this->moduleTemplate->renderContent();
74 }
75
76 /**
77 * Sets the current controller context
78 *
79 * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext Controller context which is available inside the view
80 * @return void
81 * @api
82 */
83 public function setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext) {
84 $this->templateView->setControllerContext($controllerContext);
85 }
86
87 /**
88 * Assign a value to the variable container.
89 *
90 * @param string $key The key of a view variable to set
91 * @param mixed $value The value of the view variable
92 * @return \TYPO3\CMS\Fluid\View\AbstractTemplateView the instance of this view to allow chaining
93 * @api
94 */
95 public function assign($key, $value) {
96 $this->templateView->assign($key, $value);
97 return $this;
98 }
99
100 /**
101 * Assigns multiple values to the JSON output.
102 * However, only the key "value" is accepted.
103 *
104 * @param array $values Keys and values - only a value with key "value" is considered
105 * @return \TYPO3\CMS\Fluid\View\AbstractTemplateView the instance of this view to allow chaining
106 * @api
107 */
108 public function assignMultiple(array $values) {
109 $this->templateView->assignMultiple($values);
110 return $this;
111 }
112
113 /**
114 * Checks whether a template can be resolved for the current request context.
115 *
116 * @param ControllerContext $controllerContext Controller context which is available inside the view
117 * @return bool
118 * @api
119 */
120 public function canRender(ControllerContext $controllerContext) {
121 return $this->templateView->canRender($controllerContext);
122 }
123
124 /**
125 * Init view
126 */
127 public function initializeView() {
128 $this->templateView->initializeView();
129 }
130
131 }