6b8688fd09b3166c6c7e558d6cf38a9bf2393fc9
[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 * A CLI specific response implementation
27 *
28 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
29 * @scope prototype
30 */
31 class Tx_Extbase_MVC_CLI_Response extends Tx_Extbase_MVC_Response {
32
33 /**
34 * @var integer
35 */
36 private $exitCode = 0;
37
38 /**
39 * Sets the numerical exit code which should be returned when exiting this application.
40 *
41 * @param integer $exitCode
42 * @return void
43 * @api
44 */
45 public function setExitCode($exitCode) {
46 if (!is_integer($exitCode)) {
47 throw new InvalidArgumentException(sprintf('Tried to set invalid exit code. The value must be integer, %s given.', gettype($exitCode)), 1312222064);
48 }
49 $this->exitCode = $exitCode;
50 }
51
52 /**
53 * Rets the numerical exit code which should be returned when exiting this application.
54 *
55 * @return integer
56 * @api
57 */
58 public function getExitCode() {
59 return $this->exitCode;
60 }
61
62 /**
63 * Renders and sends the whole web response
64 *
65 * @return void
66 * @api
67 */
68 public function send() {
69 if ($this->content !== NULL) {
70 echo $this->getContent();
71 }
72 }
73
74 }
75
76 ?>