TYPO3 CMS  TYPO3_7-6
RequestHandler.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
23 {
27  protected $objectManager;
28 
32  protected $dispatcher;
33 
37  protected $requestBuilder;
38 
43 
47  public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
48  {
49  $this->objectManager = $objectManager;
50  }
51 
55  public function injectDispatcher(\TYPO3\CMS\Extbase\Mvc\Dispatcher $dispatcher)
56  {
57  $this->dispatcher = $dispatcher;
58  }
59 
63  public function injectRequestBuilder(\TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder $requestBuilder)
64  {
65  $this->requestBuilder = $requestBuilder;
66  }
67 
71  public function injectEnvironmentService(\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
72  {
73  $this->environmentService = $environmentService;
74  }
75 
81  public function handleRequest()
82  {
83  $commandLine = isset($_SERVER['argv']) ? $_SERVER['argv'] : [];
84  $callingScript = array_shift($commandLine);
85  if ($callingScript !== $_SERVER['_']) {
86  $callingScript = $_SERVER['_'] . ' ' . $callingScript;
87  }
88  $request = $this->requestBuilder->build($commandLine, $callingScript . ' extbase');
90  $response = $this->objectManager->get(\TYPO3\CMS\Extbase\Mvc\Cli\Response::class);
91  $this->dispatcher->dispatch($request, $response);
92  $response->send();
93  return $response;
94  }
95 
101  public function canHandleRequest()
102  {
103  return $this->environmentService->isEnvironmentInCliMode();
104  }
105 
112  public function getPriority()
113  {
114  return 100;
115  }
116 }
injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
injectRequestBuilder(\TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder $requestBuilder)
injectDispatcher(\TYPO3\CMS\Extbase\Mvc\Dispatcher $dispatcher)
injectEnvironmentService(\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)