Example #1
0
 /**
  * Transforms the value view variable to a serializable
  * array representation using a YAML view configuration and JSON encodes
  * the result.
  *
  * @return string The JSON encoded variables
  * @api
  */
 public function render()
 {
     $response = $this->controllerContext->getResponse();
     if ($response instanceof WebResponse) {
         // @todo Ticket: #63643 This should be solved differently once request/response model is available for TSFE.
         if (!empty($GLOBALS['TSFE']) && $GLOBALS['TSFE'] instanceof TypoScriptFrontendController) {
             /** @var TypoScriptFrontendController $typoScriptFrontendController */
             $typoScriptFrontendController = $GLOBALS['TSFE'];
             if (empty($typoScriptFrontendController->config['config']['disableCharsetHeader'])) {
                 // If the charset header is *not* disabled in configuration,
                 // TypoScriptFrontendController will send the header later with the Content-Type which we set here.
                 $typoScriptFrontendController->setContentType('application/json');
             } else {
                 // Although the charset header is disabled in configuration, we *must* send a Content-Type header here.
                 // Content-Type headers optionally carry charset information at the same time.
                 // Since we have the information about the charset, there is no reason to not include the charset information although disabled in TypoScript.
                 $response->setHeader('Content-Type', 'application/json; charset=' . trim($typoScriptFrontendController->metaCharset));
             }
         } else {
             $response->setHeader('Content-Type', 'application/json');
         }
     }
     $propertiesToRender = $this->renderArray();
     return json_encode($propertiesToRender);
 }
Example #2
0
 /**
  * Transforms the value view variable to a serializable
  * array representation using a YAML view configuration and JSON encodes
  * the result.
  *
  * @return string The JSON encoded variables
  * @api
  */
 public function render()
 {
     $response = $this->controllerContext->getResponse();
     if ($response instanceof WebResponse) {
         $response->setHeader('Content-Type', 'application/json');
     }
     $propertiesToRender = $this->renderArray();
     return json_encode($propertiesToRender);
 }
Example #3
0
 /**
  * Transforms the value view variable to a serializable
  * array represantion using a YAML view configuration and JSON encodes
  * the result.
  *
  * @return string The JSON encoded variables
  * @api
  */
 public function render()
 {
     $this->controllerContext->getResponse()->setHeader('Content-Type', 'application/json');
     $propertiesToRender = $this->renderArray();
     return json_encode($propertiesToRender);
 }