コード例 #1
0
	/**
	 * Handles the request
	 *
	 * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface
	 */
	public function handleRequest() {
		$commandLine = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
		$callingScript = array_shift($commandLine);
		if ($callingScript !== $_SERVER['_']) {
			$callingScript = $_SERVER['_'] . ' ' . $callingScript;
		}
		$request = $this->requestBuilder->build($commandLine, $callingScript . ' extbase');
		/** @var $response \TYPO3\CMS\Extbase\Mvc\Cli\Response */
		$response = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Cli\Response::class);
		$this->dispatcher->dispatch($request, $response);
		$response->send();
		return $response;
	}
コード例 #2
0
 /**
  * Handles the request
  *
  * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface
  */
 public function handleRequest()
 {
     $this->boot(isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '');
     $commandLine = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
     $callingScript = array_shift($commandLine);
     if ($callingScript !== $_SERVER['_']) {
         $callingScript = $_SERVER['_'] . ' ' . $callingScript;
     }
     $this->request = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\RequestBuilder')->build($commandLine, $callingScript);
     $this->response = new \TYPO3\CMS\Extbase\Mvc\Cli\Response();
     $this->dispatcher->dispatch($this->request, $this->response);
     $this->response->send();
     $this->shutdown();
 }
コード例 #3
0
ファイル: RequestHandler.php プロジェクト: ecodev/newsletter
 /**
  * Handles a raw Ext Direct request and sends the respsonse.
  */
 public function handleRequest()
 {
     $extDirectRequest = $this->requestBuilder->build();
     $results = [];
     foreach ($extDirectRequest->getTransactions() as $transaction) {
         $transactionRequest = $transaction->buildRequest();
         $transactionResponse = $transaction->buildResponse();
         try {
             $this->dispatcher->dispatch($transactionRequest, $transactionResponse);
             $results[] = ['type' => 'rpc', 'tid' => $transaction->getTid(), 'action' => $transaction->getAction(), 'method' => $transaction->getMethod(), 'result' => $transactionResponse->getResult()];
         } catch (Exception $exception) {
             $exceptionMessage = $this->exposeExceptionInformation ? $exception->getMessage() : 'An internal error occured';
             $exceptionWhere = $this->exposeExceptionInformation ? $exception->getTraceAsString() : '';
             $results[] = ['type' => 'exception', 'tid' => $transaction->getTid(), 'message' => $exceptionMessage, 'where' => $exceptionWhere];
         }
     }
     return $this->sendResponse($results, $extDirectRequest);
 }
コード例 #4
0
ファイル: TaskExecutor.php プロジェクト: khanhdeux/typo3test
 /**
  * Execute Task
  *
  * If errors occur during Task execution they are thrown as Exceptions which
  * must be caught manually if you manually execute Tasks through your code.
  *
  * @param \TYPO3\CMS\Extbase\Scheduler\Task $task the task to execute
  * @return void
  */
 public function execute(\TYPO3\CMS\Extbase\Scheduler\Task $task)
 {
     $commandIdentifier = $task->getCommandIdentifier();
     list($extensionKey, $controllerName, $commandName) = explode(':', $commandIdentifier);
     $extensionName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToUpperCamelCase($extensionKey);
     $this->initialize(array('extensionName' => $extensionName));
     // execute command
     $command = $this->commandManager->getCommandByIdentifier($commandIdentifier);
     $this->request->setControllerObjectName($command->getControllerClassName());
     $this->request->setControllerCommandName($command->getControllerCommandName());
     $this->request->setArguments($task->getArguments());
     $this->dispatcher->dispatch($this->request, $this->response);
     $this->shutdown();
 }
コード例 #5
0
 /**
  * Dispatch Request
  *
  * Dispatches (as a completely new Request) a Request that will
  * execute a configured Plugin->Controller->action() which means
  * that the Plugin, Controller and Action you use must be allowed
  * by the plugin configuration of the target controller.
  *
  * @param string|NULL $action
  * @param string|NULL $controller
  * @param string|NULL $extensionName
  * @param string|NULL $pluginName
  * @param string|NULL $vendorName
  * @param array $arguments
  * @param integer $pageUid
  * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface
  * @throws \Exception
  * @api
  */
 public function render($action = NULL, $controller = NULL, $extensionName = NULL, $pluginName = NULL, $vendorName = NULL, array $arguments = array(), $pageUid = 0)
 {
     $contentObjectBackup = $this->configurationManager->getContentObject();
     if (TRUE === isset($this->request)) {
         $configurationBackup = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $this->request->getControllerExtensionName(), $this->request->getPluginName());
     }
     $temporaryContentObject = new \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer();
     /** @var \TYPO3\CMS\Extbase\Mvc\Web\Request $request */
     $request = $this->objectManager->get($this->requestType);
     $request->setControllerActionName($action);
     $request->setControllerName($controller);
     $request->setPluginName($pluginName);
     $request->setControllerExtensionName($extensionName);
     $request->setArguments($arguments);
     // TODO: remove for 6.2 LTS
     if (FALSE === empty($vendorName)) {
         $request->setControllerVendorName($vendorName);
     }
     try {
         /** @var \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response */
         $response = $this->objectManager->get($this->responseType);
         $this->configurationManager->setContentObject($temporaryContentObject);
         $this->configurationManager->setConfiguration($this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, $extensionName, $pluginName));
         $this->dispatcher->dispatch($request, $response);
         $this->configurationManager->setContentObject($contentObjectBackup);
         if (TRUE === isset($configurationBackup)) {
             $this->configurationManager->setConfiguration($configurationBackup);
         }
         unset($pageUid);
         return $response;
     } catch (\Exception $error) {
         if (FALSE === (bool) $this->arguments['graceful']) {
             throw $error;
         }
         if (FALSE === empty($this->arguments['onError'])) {
             return sprintf($this->arguments['onError'], array($error->getMessage()), $error->getCode());
         }
         return $error->getMessage() . ' (' . $error->getCode() . ')';
     }
     return NULL;
 }
コード例 #6
0
 /**
  * Dispatches a request to a controller and initializes the security framework.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\RequestInterface $request The request to dispatch
  * @param \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response The response, to be modified by the controller
  * @param \EssentialDots\ExtbaseHijax\Event\Listener $listener Listener
  * @return void
  */
 public function dispatch(\TYPO3\CMS\Extbase\Mvc\RequestInterface $request, \TYPO3\CMS\Extbase\Mvc\ResponseInterface $response, \EssentialDots\ExtbaseHijax\Event\Listener $listener = NULL)
 {
     /* @var $request \TYPO3\CMS\Extbase\Mvc\Request */
     $this->currentRequest = $request;
     array_push($this->requestsStack, $this->currentRequest);
     if (defined('TYPO3_cliMode') && TYPO3_cliMode === TRUE) {
         parent::dispatch($request, $response);
     } else {
         array_push($this->listenersStack, $this->currentListener);
         if ($listener) {
             $this->currentListener = $listener;
         } else {
             $this->currentListener = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('EssentialDots\\ExtbaseHijax\\Event\\Listener', $request);
         }
         if (!$this->serviceContent->getExecuteExtbasePlugins()) {
             $this->listenerFactory->persist($this->currentListener);
             $this->serviceContent->setCurrentListener($this->currentListener);
         } else {
             $this->hijaxEventDispatcher->startContentElement();
             try {
                 parent::dispatch($request, $response);
             } catch (\TYPO3\CMS\Extbase\Mvc\Controller\Exception\RequiredArgumentMissingException $requiredArgumentMissingException) {
                 try {
                     // this happens with simple reload on pages where some argument is required
                     $configuration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
                     $defaultControllerName = current(array_keys($configuration['controllerConfiguration']));
                     $allowedControllerActions = array();
                     foreach ($configuration['controllerConfiguration'] as $controllerName => $controllerActions) {
                         $allowedControllerActions[$controllerName] = $controllerActions['actions'];
                     }
                     $defaultActionName = is_array($allowedControllerActions[$request->getControllerName()]) ? current($allowedControllerActions[$request->getControllerName()]) : '';
                     // try to run the current controller with the default action
                     $request->setDispatched(false);
                     $request->setControllerActionName($defaultActionName);
                     parent::dispatch($request, $response);
                 } catch (\TYPO3\CMS\Extbase\Mvc\Controller\Exception\RequiredArgumentMissingException $requiredArgumentMissingException) {
                     if ($defaultControllerName != $request->getControllerName()) {
                         $request->setControllerName($defaultControllerName);
                         $defaultActionName = is_array($allowedControllerActions[$defaultControllerName]) ? current($allowedControllerActions[$defaultControllerName]) : '';
                         // try to run the default plugin controller with the default action
                         $request->setDispatched(false);
                         $request->setControllerActionName($defaultActionName);
                         parent::dispatch($request, $response);
                     }
                 }
             }
             if ($this->hijaxEventDispatcher->getIsHijaxElement()) {
                 $this->listenerFactory->persist($this->currentListener);
             }
             if (($this->ajaxDispatcher->getIsActive() || $this->hijaxEventDispatcher->getIsHijaxElement()) && !$this->ajaxDispatcher->getPreventMarkupUpdateOnAjaxLoad()) {
                 $currentListeners = $this->hijaxEventDispatcher->getListeners('', TRUE);
                 $signature = $this->getCurrentListener()->getId() . '(' . $this->convertArrayToCSV(array_keys($currentListeners)) . '); ';
                 $content = $response->getContent();
                 $content = '<!-- ###EVENT_LISTENER_' . self::$id . '### START ' . $signature . ' -->' . $content . '<!-- ###EVENT_LISTENER_' . self::$id . '### END -->';
                 if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('eID') && \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('eID') != 'extbase_hijax_dispatcher') {
                     $this->hijaxEventDispatcher->replaceXMLCommentsWithDivs($content, 'html');
                 }
                 $response->setContent($content);
                 $this->extensionConfiguration->setNextElementId(++self::$id);
             }
             $this->hijaxEventDispatcher->endContentElement();
         }
         $this->currentListener = array_pop($this->listenersStack);
     }
     $this->currentRequest = array_pop($this->requestsStack);
 }