|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de> 00006 * All rights reserved 00007 * 00008 * This class is a backport of the corresponding class of FLOW3. 00009 * All credits go to the v5 team. 00010 * 00011 * This script is part of the TYPO3 project. The TYPO3 project is 00012 * free software; you can redistribute it and/or modify 00013 * it under the terms of the GNU General Public License as published by 00014 * the Free Software Foundation; either version 2 of the License, or 00015 * (at your option) any later version. 00016 * 00017 * The GNU General Public License can be found at 00018 * http://www.gnu.org/copyleft/gpl.html. 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00027 00028 /** 00029 * An abstract View 00030 * 00031 * @package Extbase 00032 * @subpackage MVC\View 00033 * @version $ID:$ 00034 * @api 00035 */ 00036 abstract class Tx_Extbase_MVC_View_AbstractView implements Tx_Extbase_MVC_View_ViewInterface { 00037 00038 /** 00039 * @var Tx_Extbase_MVC_Controller_ControllerContext 00040 * @api 00041 */ 00042 protected $controllerContext; 00043 00044 /** 00045 * View variables and their values 00046 * @var array 00047 * @see assign() 00048 */ 00049 protected $variables = array(); 00050 00051 /** 00052 * Sets the current controller context 00053 * 00054 * @param Tx_Extbase_MVC_Controller_ControllerContext $controllerContext 00055 * @return void 00056 */ 00057 public function setControllerContext(Tx_Extbase_MVC_Controller_ControllerContext $controllerContext) { 00058 $this->controllerContext = $controllerContext; 00059 } 00060 00061 /** 00062 * Add a variable to $this->viewData. 00063 * Can be chained, so $this->view->assign(..., ...)->assign(..., ...); is possible 00064 * 00065 * @param string $key Key of variable 00066 * @param object $value Value of object 00067 * @return Tx_Extbase_MVC_View_AbstractView an instance of $this, to enable chaining 00068 * @api 00069 */ 00070 public function assign($key, $value) { 00071 $this->variables[$key] = $value; 00072 return $this; 00073 } 00074 00075 /** 00076 * Add multiple variables to $this->viewData. 00077 * 00078 * @param array $values array in the format array(key1 => value1, key2 => value2). 00079 * @return Tx_Extbase_MVC_View_AbstractView an instance of $this, to enable chaining 00080 * @api 00081 */ 00082 public function assignMultiple(array $values) { 00083 foreach($values as $key => $value) { 00084 $this->assign($key, $value); 00085 } 00086 return $this; 00087 } 00088 00089 /** 00090 * Tells if the view implementation can render the view for the given context. 00091 * 00092 * By default we assume that the view implementation can handle all kinds of 00093 * contexts. Override this method if that is not the case. 00094 * 00095 * @param Tx_Extbase_MVC_Controller_ControllerContext $controllerContext 00096 * @return boolean TRUE if the view has something useful to display, otherwise FALSE 00097 * @api 00098 */ 00099 public function canRender(Tx_Extbase_MVC_Controller_ControllerContext $controllerContext) { 00100 return TRUE; 00101 } 00102 00103 /** 00104 * Initializes this view. 00105 * 00106 * Override this method for initializing your concrete view implementation. 00107 * 00108 * @return void 00109 * @api 00110 */ 00111 public function initializeView() { 00112 } 00113 } 00114 ?>
1.8.0