[+FEATURE] Extbase (MVC): Make response format configurable in TypoScript
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 11 Jun 2011 17:21:31 +0000 (19:21 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 11 Jun 2011 17:21:31 +0000 (19:21 +0200)
Allow configuring the response format via TypoScript, so it doesn't
necessarily need to be passed by URL. If a separate page is used
for a certain format/functionality this allows to configure the
desired format internally.

Thanks to Christian Zenker

Change-Id: Iec33afb8daae8074202cf1188ee0a32711ce7b18
Resolves: #9216

typo3/sysext/extbase/Classes/MVC/Web/RequestBuilder.php

index 9623123..2a87044 100644 (file)
@@ -70,6 +70,13 @@ class Tx_Extbase_MVC_Web_RequestBuilder implements t3lib_Singleton {
        protected $defaultActionName;
 
        /**
+        * The default format of the response object
+        *
+        * @var string
+        */
+       protected $defaultFormat = 'html';
+
+       /**
         * The allowed actions of the controller. This actions can be called via $_GET and $_POST.
         *
         * @var array
@@ -132,6 +139,9 @@ class Tx_Extbase_MVC_Web_RequestBuilder implements t3lib_Singleton {
                        $allowedControllerActions[$controllerName] = $controllerActions['actions'];
                }
                $this->allowedControllerActions = $allowedControllerActions;
+               if (!empty($configuration['format'])) {
+                       $this->defaultFormat = $configuration['format'];
+               }
        }
 
        /**
@@ -180,6 +190,8 @@ class Tx_Extbase_MVC_Web_RequestBuilder implements t3lib_Singleton {
 
                if (is_string($parameters['format']) && (strlen($parameters['format']))) {
                        $request->setFormat(filter_var($parameters['format'], FILTER_SANITIZE_STRING));
+               } else {
+                       $request->setFormat($this->defaultFormat);
                }
 
                foreach ($parameters as $argumentName => $argumentValue) {