1<?php 2 3/* 4 * This file is part of the TYPO3 CMS project. 5 * 6 * It is free software; you can redistribute it and/or modify it under 7 * the terms of the GNU General Public License, either version 2 8 * of the License, or any later version. 9 * 10 * For the full copyright and license information, please read the 11 * LICENSE.txt file that was distributed with this source code. 12 * 13 * The TYPO3 project - inspiring people to share! 14 */ 15 16namespace TYPO3\CMS\Extbase\Mvc\Controller; 17 18use TYPO3\CMS\Core\Messaging\FlashMessageService; 19use TYPO3\CMS\Extbase\Mvc\Request; 20use TYPO3\CMS\Extbase\Mvc\Response; 21use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; 22use TYPO3\CMS\Extbase\Service\ExtensionService; 23 24/** 25 * The controller context contains information from the controller 26 */ 27class ControllerContext 28{ 29 /** 30 * @var \TYPO3\CMS\Extbase\Mvc\Request 31 */ 32 protected $request; 33 34 /** 35 * @var \TYPO3\CMS\Extbase\Mvc\Response 36 */ 37 protected $response; 38 39 /** 40 * @var \TYPO3\CMS\Extbase\Mvc\Controller\Arguments 41 */ 42 protected $arguments; 43 44 /** 45 * @var \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder 46 */ 47 protected $uriBuilder; 48 49 /** 50 * @var string 51 */ 52 protected $flashMessageQueueDefaultIdentifier; 53 54 /** 55 * @var \TYPO3\CMS\Core\Messaging\FlashMessageService 56 */ 57 protected $flashMessageService; 58 59 /** 60 * @var \TYPO3\CMS\Extbase\Service\ExtensionService 61 */ 62 protected $extensionService; 63 64 /** 65 * @param \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService 66 */ 67 public function injectFlashMessageService(FlashMessageService $flashMessageService) 68 { 69 $this->flashMessageService = $flashMessageService; 70 } 71 72 /** 73 * @param \TYPO3\CMS\Extbase\Service\ExtensionService $extensionService 74 */ 75 public function injectExtensionService(ExtensionService $extensionService) 76 { 77 $this->extensionService = $extensionService; 78 } 79 80 /** 81 * Set the request of the controller 82 * 83 * @param \TYPO3\CMS\Extbase\Mvc\Request $request 84 */ 85 public function setRequest(Request $request) 86 { 87 $this->request = $request; 88 } 89 90 /** 91 * Get the request of the controller 92 * 93 * @return \TYPO3\CMS\Extbase\Mvc\Request 94 */ 95 public function getRequest() 96 { 97 return $this->request; 98 } 99 100 /** 101 * Set the response of the controller 102 * 103 * @param \TYPO3\CMS\Extbase\Mvc\Response $response 104 */ 105 public function setResponse(Response $response) 106 { 107 $this->response = $response; 108 } 109 110 /** 111 * Get the response of the controller 112 * 113 * @return \TYPO3\CMS\Extbase\Mvc\Response 114 */ 115 public function getResponse() 116 { 117 return $this->response; 118 } 119 120 /** 121 * Set the arguments of the controller 122 * 123 * @param \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $arguments 124 */ 125 public function setArguments(Arguments $arguments) 126 { 127 $this->arguments = $arguments; 128 } 129 130 /** 131 * Get the arguments of the controller 132 * 133 * @return \TYPO3\CMS\Extbase\Mvc\Controller\Arguments 134 */ 135 public function getArguments() 136 { 137 return $this->arguments; 138 } 139 140 /** 141 * @param \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder $uriBuilder 142 */ 143 public function setUriBuilder(UriBuilder $uriBuilder) 144 { 145 $this->uriBuilder = $uriBuilder; 146 } 147 148 /** 149 * @return \TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder 150 */ 151 public function getUriBuilder() 152 { 153 return $this->uriBuilder; 154 } 155 156 /** 157 * @param string $identifier Queue-identifier 158 * @return \TYPO3\CMS\Core\Messaging\FlashMessageQueue 159 */ 160 public function getFlashMessageQueue($identifier = null) 161 { 162 if ($identifier === null) { 163 if ($this->flashMessageQueueDefaultIdentifier === null) { 164 // cache the default-identifier for performance-reasons 165 $this->flashMessageQueueDefaultIdentifier = 'extbase.flashmessages.' . $this->extensionService->getPluginNamespace($this->request->getControllerExtensionName(), $this->request->getPluginName()); 166 } 167 $identifier = $this->flashMessageQueueDefaultIdentifier; 168 } 169 return $this->flashMessageService->getMessageQueueByIdentifier($identifier); 170 } 171} 172