[CLEANUP] Remove old SVN comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Scheduler / Task.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Scheduler;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011 Claus Due, Wildside A/S <claus@wildside.dk>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26 /**
27 * Scheduler task to execute CommandController commands
28 */
29 class Task extends \TYPO3\CMS\Scheduler\Task {
30
31 /**
32 * @var string
33 */
34 protected $commandIdentifier;
35
36 /**
37 * @var array
38 */
39 protected $arguments = array();
40
41 /**
42 * @var array
43 */
44 protected $defaults = array();
45
46 /**
47 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
48 */
49 protected $objectManager;
50
51 /**
52 * @var \TYPO3\CMS\Extbase\Mvc\Cli\CommandManager
53 */
54 protected $commandManager;
55
56 /**
57 * @var \TYPO3\CMS\Extbase\Scheduler\TaskExecutor
58 */
59 protected $taskExecutor;
60
61 /**
62 * Function execute from the Scheduler
63 *
64 * @return boolean TRUE on successful execution, FALSE on error
65 */
66 public function execute() {
67 $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
68 $this->commandManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\CommandManager');
69 $this->taskExecutor = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Scheduler\\TaskExecutor');
70 try {
71 $this->taskExecutor->execute($this);
72 return TRUE;
73 } catch (\Exception $e) {
74 \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($e->getMessage(), $this->commandIdentifier, 3);
75 return FALSE;
76 }
77 }
78
79 /**
80 * @param string $commandIdentifier
81 */
82 public function setCommandIdentifier($commandIdentifier) {
83 $this->commandIdentifier = $commandIdentifier;
84 }
85
86 /**
87 * @return string
88 */
89 public function getCommandIdentifier() {
90 return $this->commandIdentifier;
91 }
92
93 /**
94 * @param array $arguments
95 */
96 public function setArguments($arguments) {
97 $this->arguments = $arguments;
98 }
99
100 /**
101 * @return array
102 */
103 public function getArguments() {
104 return $this->arguments;
105 }
106
107 /**
108 * @param array $defaults
109 */
110 public function setDefaults(array $defaults) {
111 $this->defaults = $defaults;
112 }
113
114 /**
115 * @return array
116 */
117 public function getDefaults() {
118 return $this->defaults;
119 }
120
121 /**
122 * @param string $argumentName
123 * @param mixed $argumentValue
124 */
125 public function addDefaultValue($argumentName, $argumentValue) {
126 if (is_bool($argumentValue)) {
127 $argumentValue = intval($argumentValue);
128 }
129 $this->defaults[$argumentName] = $argumentValue;
130 }
131
132 /**
133 * Return a text representation of the selected command and arguments
134 *
135 * @return string Information to display
136 */
137 public function getAdditionalInformation() {
138 $label = $this->commandIdentifier;
139 if (count($this->arguments) > 0) {
140 $arguments = array();
141 foreach ($this->arguments as $argumentName => $argumentValue) {
142 if ($argumentValue != $this->defaults[$argumentName]) {
143 array_push($arguments, $argumentName . '=' . $argumentValue);
144 }
145 }
146 $label .= ' ' . implode(', ', $arguments);
147 }
148 return $label;
149 }
150
151 }
152
153
154 ?>