Exemplo n.º 1
0
 /**
  * Creates a request an dispatches it to a controller.
  *
  * @param string $content The content
  * @param array $configuration The TS configuration array
  * @return string $content The processed content
  */
 public function dispatch($content, $configuration)
 {
     // FIXME Remove the next lines. These are only there to generate the ext_autoload.php file
     //$extutil = new Tx_Extbase_Utility_Extension;
     //$extutil->createAutoloadRegistryForExtension('extbase', t3lib_extMgm::extPath('extbase'));
     //$extutil->createAutoloadRegistryForExtension('fluid', t3lib_extMgm::extPath('fluid'));
     $this->timeTrackPush('Extbase is called.', '');
     $this->timeTrackPush('Extbase gets initialized.', '');
     if (!is_array($configuration)) {
         t3lib_div::sysLog('Extbase was not able to dispatch the request. No configuration.', 'extbase', t3lib_div::SYSLOG_SEVERITY_ERROR);
         return $content;
     }
     $this->initializeConfigurationManagerAndFrameworkConfiguration($configuration);
     $requestBuilder = t3lib_div::makeInstance('Tx_Extbase_MVC_Web_RequestBuilder');
     $request = $requestBuilder->initialize(self::$extbaseFrameworkConfiguration);
     $request = $requestBuilder->build();
     if (isset($this->cObj->data) && is_array($this->cObj->data)) {
         // we need to check the above conditions as cObj is not available in Backend.
         $request->setContentObjectData($this->cObj->data);
         $request->setIsCached($this->cObj->getUserObjectType() == tslib_cObj::OBJECTTYPE_USER);
     }
     $response = t3lib_div::makeInstance('Tx_Extbase_MVC_Web_Response');
     // Request hash service
     $requestHashService = t3lib_div::makeInstance('Tx_Extbase_Security_Channel_RequestHashService');
     // singleton
     $requestHashService->verifyRequest($request);
     $persistenceManager = self::getPersistenceManager();
     $this->timeTrackPull();
     $this->timeTrackPush('Extbase dispatches request.', '');
     $dispatchLoopCount = 0;
     while (!$request->isDispatched()) {
         if ($dispatchLoopCount++ > 99) {
             throw new Tx_Extbase_MVC_Exception_InfiniteLoop('Could not ultimately dispatch the request after ' . $dispatchLoopCount . ' iterations.', 1217839467);
         }
         $controller = $this->getPreparedController($request);
         try {
             $controller->processRequest($request, $response);
         } catch (Tx_Extbase_MVC_Exception_StopAction $ignoredException) {
         }
     }
     $this->timeTrackPull();
     $this->timeTrackPush('Extbase persists all changes.', '');
     $flashMessages = t3lib_div::makeInstance('Tx_Extbase_MVC_Controller_FlashMessages');
     // singleton
     $flashMessages->persist();
     $persistenceManager->persistAll();
     $this->timeTrackPull();
     self::$reflectionService->shutdown();
     if (count($response->getAdditionalHeaderData()) > 0) {
         $GLOBALS['TSFE']->additionalHeaderData[$request->getControllerExtensionName()] = implode("\n", $response->getAdditionalHeaderData());
     }
     $response->sendHeaders();
     $this->timeTrackPull();
     return $response->getContent();
 }
Exemplo n.º 2
0
 /**
  * Add a JS file
  *
  * @param string  $path
  * @param boolean $includeInFooter
  * @param string  $id
  * @return void
  */
 public function addJS($path, $includeInFooter = false, $id = '')
 {
     if ($this->cObj->getUserObjectType() == \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::OBJECTTYPE_USER_INT) {
         $GLOBALS['TSFE']->additionalHeaderData[$this->extKey . $id . 'js'] = '<script src="' . trim($path) . '" type="text/javascript"></script>';
     } else {
         if ($includeInFooter === 1) {
             $includeJs = 'includeJSFooter.';
         } else {
             $includeJs = 'includeJS.';
         }
         $GLOBALS['TSFE']->pSetup[$includeJs][] = trim($path);
     }
 }