[CLEANUP] Improve the @param/@return/@var PHPDoc
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Mvc / View / AbstractView.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Mvc\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 /**
18 * An abstract View
19 *
20 * @api
21 */
22 abstract class AbstractView implements \TYPO3\CMS\Extbase\Mvc\View\ViewInterface {
23
24 /**
25 * @var \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
26 * @api
27 */
28 protected $controllerContext;
29
30 /**
31 * View variables and their values
32 *
33 * @var array
34 * @see assign()
35 */
36 protected $variables = array();
37
38 /**
39 * Sets the current controller context
40 *
41 * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
42 * @return void
43 */
44 public function setControllerContext(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext) {
45 $this->controllerContext = $controllerContext;
46 }
47
48 /**
49 * Add a variable to $this->viewData.
50 * Can be chained, so $this->view->assign(..., ...)->assign(..., ...); is possible
51 *
52 * @param string $key Key of variable
53 * @param mixed $value Value of object
54 * @return \TYPO3\CMS\Extbase\Mvc\View\AbstractView an instance of $this, to enable chaining
55 * @api
56 */
57 public function assign($key, $value) {
58 $this->variables[$key] = $value;
59 return $this;
60 }
61
62 /**
63 * Add multiple variables to $this->viewData.
64 *
65 * @param array $values array in the format array(key1 => value1, key2 => value2).
66 * @return \TYPO3\CMS\Extbase\Mvc\View\AbstractView an instance of $this, to enable chaining
67 * @api
68 */
69 public function assignMultiple(array $values) {
70 foreach ($values as $key => $value) {
71 $this->assign($key, $value);
72 }
73 return $this;
74 }
75
76 /**
77 * Tells if the view implementation can render the view for the given context.
78 *
79 * By default we assume that the view implementation can handle all kinds of
80 * contexts. Override this method if that is not the case.
81 *
82 * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext
83 * @return bool TRUE if the view has something useful to display, otherwise FALSE
84 * @api
85 */
86 public function canRender(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $controllerContext) {
87 return TRUE;
88 }
89
90 /**
91 * Initializes this view.
92 *
93 * Override this method for initializing your concrete view implementation.
94 *
95 * @return void
96 * @api
97 */
98 public function initializeView() {
99 }
100
101 }