[+FEATURE] Backport CommandController Implementation
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / MVC / CLI / Response.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 * All rights reserved
5 *
6 * This class is a backport of the corresponding class of FLOW3.
7 * All credits go to the v5 team.
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 *
18 * This script is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This copyright notice MUST APPEAR in all copies of the script!
24 ***************************************************************/
25
26 /**
27 * A CLI specific response implementation
28 *
29 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
30 * @scope prototype
31 */
32 class Tx_Extbase_MVC_CLI_Response extends Tx_Extbase_MVC_Response {
33
34 /**
35 * @var integer
36 */
37 private $exitCode = 0;
38
39 /**
40 * Sets the numerical exit code which should be returned when exiting this application.
41 *
42 * @param integer $exitCode
43 * @return void
44 * @api
45 */
46 public function setExitCode($exitCode) {
47 if (!is_integer($exitCode)) {
48 throw new InvalidArgumentException(sprintf('Tried to set invalid exit code. The value must be integer, %s given.', gettype($exitCode)), 1312222064);
49 }
50 $this->exitCode = $exitCode;
51 }
52
53 /**
54 * Rets the numerical exit code which should be returned when exiting this application.
55 *
56 * @return integer
57 * @api
58 */
59 public function getExitCode() {
60 return $this->exitCode;
61 }
62
63 /**
64 * Renders and sends the whole web response
65 *
66 * @return void
67 * @api
68 */
69 public function send() {
70 if ($this->content !== NULL) {
71 echo $this->getContent();
72 }
73 }
74
75 }
76
77 ?>