TYPO3 API  SVNRelease
WidgetRequestHandler.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This script belongs to the FLOW3 package "Fluid".                      *
00005  *                                                                        *
00006  * It is free software; you can redistribute it and/or modify it under    *
00007  * the terms of the GNU Lesser General Public License as published by the *
00008  * Free Software Foundation, either version 3 of the License, or (at your *
00009  * option) any later version.                                             *
00010  *                                                                        *
00011  * This script is distributed in the hope that it will be useful, but     *
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
00013  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
00014  * General Public License for more details.                               *
00015  *                                                                        *
00016  * You should have received a copy of the GNU Lesser General Public       *
00017  * License along with the script.                                         *
00018  * If not, see http://www.gnu.org/licenses/lgpl.html                      *
00019  *                                                                        *
00020  * The TYPO3 project - inspiring people to share!                         *
00021  *                                                                        */
00022 
00023 /**
00024  * Widget request handler, which handles the request if
00025  * f3-fluid-widget-id is found.
00026  *
00027  * This Request Handler gets the WidgetRequestBuilder injected.
00028  *
00029  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
00030  */
00031 class Tx_Fluid_Core_Widget_WidgetRequestHandler extends Tx_Extbase_MVC_Web_AbstractRequestHandler {
00032 
00033     /**
00034      * @var Tx_Fluid_Core_Widget_AjaxWidgetContextHolder
00035      */
00036     protected $ajaxWidgetContextHolder;
00037 
00038     /**
00039      * @var Tx_Extbase_Configuration_ConfigurationManagerInterface
00040      */
00041     protected $configurationManager;
00042 
00043     /**
00044      * @param Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager
00045      * @return void
00046      */
00047     public function injectConfigurationManager(Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager) {
00048         $this->configurationManager = $configurationManager;
00049     }
00050 
00051     /**
00052      * @param Tx_Fluid_Core_Widget_AjaxWidgetContextHolder $ajaxWidgetContextHolder
00053      * @return void
00054      * @author Sebastian Kurfürst <sebastian@typo3.org>
00055      */
00056     public function injectAjaxWidgetContextHolder(Tx_Fluid_Core_Widget_AjaxWidgetContextHolder $ajaxWidgetContextHolder) {
00057         $this->ajaxWidgetContextHolder = $ajaxWidgetContextHolder;
00058     }
00059 
00060     /**
00061      * Injects the request handler
00062      *
00063      * @param Tx_Fluid_Core_Widget_WidgetRequestBuilder $requestBuilder
00064      * @return void
00065      */
00066     public function injectRequestBuilder(Tx_Fluid_Core_Widget_WidgetRequestBuilder $requestBuilder) {
00067         $this->requestBuilder = $requestBuilder;
00068     }
00069 
00070     /**
00071      * Handles the web request. The response will automatically be sent to the client.
00072      *
00073      * @return Tx_Extbase_MVC_Web_Response
00074      */
00075     public function handleRequest() {
00076         $request = $this->requestBuilder->build();
00077         if (isset($this->cObj->data) && is_array($this->cObj->data)) {
00078             $request->setContentObjectData($this->cObj->data);
00079         }
00080         $response = $this->objectManager->create('Tx_Extbase_MVC_Web_Response');
00081 
00082         $this->dispatcher->dispatch($request, $response);
00083         return $response;
00084     }
00085 
00086     /**
00087      * @return boolean TRUE if it is an AJAX widget request
00088      * @author Sebastian Kurfürst <sebastian@typo3.org>
00089      */
00090     public function canHandleRequest() {
00091         $rawGetArguments = t3lib_div::_GET();
00092         return isset($rawGetArguments['fluid-widget-id']);
00093     }
00094 
00095     /**
00096      * This request handler has a higher priority than the default request handler.
00097      *
00098      * @return integer
00099      * @author Sebastian Kurfürst <sebastian@typo3.org>
00100      */
00101     public function getPriority() {
00102         return 200;
00103     }
00104 }
00105 
00106 ?>