[CLEANUP] Adjust code to coding guidelines
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Mvc / Cli / RequestHandler.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Mvc\Cli;
3
4 /***************************************************************
5 * Copyright notice
6 * All rights reserved
7 *
8 * This class is a backport of the corresponding class of TYPO3 Flow.
9 * All credits go to the TYPO3 Flow team.
10 *
11 * This script is part of the TYPO3 project. The TYPO3 project is
12 * free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * The GNU General Public License can be found at
18 * http://www.gnu.org/copyleft/gpl.html.
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * The generic command line interface request handler for the MVC framework.
29 *
30 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
31 */
32 class RequestHandler implements \TYPO3\CMS\Extbase\Mvc\RequestHandlerInterface {
33
34 /**
35 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
36 */
37 protected $objectManager;
38
39 /**
40 * @var \TYPO3\CMS\Extbase\Mvc\Dispatcher
41 */
42 protected $dispatcher;
43
44 /**
45 * @var \TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder
46 */
47 protected $requestBuilder;
48
49 /**
50 * @var \TYPO3\CMS\Extbase\Mvc\Controller\FlashMessageContainer
51 */
52 protected $flashMessageContainer;
53
54 /**
55 * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
56 * @return void
57 */
58 public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager) {
59 $this->objectManager = $objectManager;
60 }
61
62 /**
63 * @param \TYPO3\CMS\Extbase\Mvc\Controller\FlashMessageContainer $flashMessageContainer
64 * @return void
65 */
66 public function injectFlashMessageContainer(\TYPO3\CMS\Extbase\Mvc\Controller\FlashMessageContainer $flashMessageContainer) {
67 $this->flashMessageContainer = $flashMessageContainer;
68 }
69
70 /**
71 * @param \TYPO3\CMS\Extbase\Mvc\Dispatcher $dispatcher
72 * @return void
73 */
74 public function injectDispatcher(\TYPO3\CMS\Extbase\Mvc\Dispatcher $dispatcher) {
75 $this->dispatcher = $dispatcher;
76 }
77
78 /**
79 * @param \TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder $requestBuilder
80 * @return void
81 */
82 public function injectRequestBuilder(\TYPO3\CMS\Extbase\Mvc\Cli\RequestBuilder $requestBuilder) {
83 $this->requestBuilder = $requestBuilder;
84 }
85
86 /**
87 * Handles the request
88 *
89 * @return void
90 * @author Robert Lemke <robert@typo3.org>
91 */
92 public function handleRequest() {
93 $request = $this->requestBuilder->build();
94 /** @var $response \TYPO3\CMS\Extbase\Mvc\Cli\Response */
95 $response = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Response');
96 $this->dispatcher->dispatch($request, $response);
97 $response->send();
98 }
99
100 /**
101 * This request handler can handle any command line request.
102 *
103 * @return boolean If the request is a command line request, TRUE otherwise FALSE
104 * @author Karsten Dambekalns <karsten@typo3.org>
105 */
106 public function canHandleRequest() {
107 return PHP_SAPI === 'cli';
108 }
109
110 /**
111 * Returns the priority - how eager the handler is to actually handle the
112 * request.
113 *
114 * @return integer The priority of the request handler.
115 * @author Robert Lemke <robert@typo3.org>
116 */
117 public function getPriority() {
118 return 90;
119 }
120 }
121
122 ?>