TYPO3 API  SVNRelease
WidgetRequestBuilder.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  * Builds the WidgetRequest if an AJAX widget is called.
00025  *
00026  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
00027  */
00028 class Tx_Fluid_Core_Widget_WidgetRequestBuilder extends Tx_Extbase_MVC_Web_RequestBuilder {
00029 
00030     /**
00031      * @var Tx_Fluid_Core_Widget_AjaxWidgetContextHolder
00032      */
00033     private $ajaxWidgetContextHolder;
00034 
00035     /**
00036      * @param Tx_Fluid_Core_Widget_AjaxWidgetContextHolder $ajaxWidgetContextHolder
00037      * @return void
00038      * @author Sebastian Kurfürst <sebastian@typo3.org>
00039      */
00040     public function injectAjaxWidgetContextHolder(Tx_Fluid_Core_Widget_AjaxWidgetContextHolder $ajaxWidgetContextHolder) {
00041         $this->ajaxWidgetContextHolder = $ajaxWidgetContextHolder;
00042     }
00043 
00044     /**
00045      * Builds a widget request object from the raw HTTP information
00046      *
00047      * @return Tx_Fluid_Core_Widget_WidgetRequest The widget request as an object
00048      * @author Sebastian Kurfürst <sebastian@typo3.org>
00049      */
00050     public function build() {
00051         $request = $this->objectManager->create('Tx_Fluid_Core_Widget_WidgetRequest');
00052         $request->setRequestURI(t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'));
00053         $request->setBaseURI(t3lib_div::getIndpEnv('TYPO3_SITE_URL'));
00054         $request->setMethod((isset($_SERVER['REQUEST_METHOD'])) ? $_SERVER['REQUEST_METHOD'] : NULL);
00055         if (strtolower($_SERVER['REQUEST_METHOD']) === 'post') {
00056             $request->setArguments(t3lib_div::_POST());
00057         } else {
00058             $request->setArguments(t3lib_div::_GET());
00059         }
00060 
00061         $rawGetArguments = t3lib_div::_GET();
00062             // TODO: rename to @action, to be consistent with normal naming?
00063         if (isset($rawGetArguments['action'])) {
00064             $request->setControllerActionName($rawGetArguments['action']);
00065         }
00066 
00067         $widgetContext = $this->ajaxWidgetContextHolder->get($rawGetArguments['fluid-widget-id']);
00068         $request->setWidgetContext($widgetContext);
00069         return $request;
00070     }
00071 }
00072 
00073 ?>