2 /***************************************************************
5 * (c) 2011 Claus Due, Wildside A/S <claus@wildside.dk>
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
26 * Scheduler task to execute CommandController commands
29 * @subpackage Scheduler
31 class Tx_Extbase_Scheduler_Task
extends Tx_Scheduler_Task
{
36 protected $commandIdentifier;
41 protected $arguments = array();
46 protected $defaults = array();
49 * @var Tx_Extbase_Object_ObjectManagerInterface
51 protected $objectManager;
54 * @var Tx_Extbase_MVC_CLI_CommandManager
56 protected $commandManager;
59 * @var Tx_Extbase_Scheduler_TaskExecutor
61 protected $taskExecutor;
64 * Function execute from the Scheduler
66 * @return boolean TRUE on successful execution, FALSE on error
68 public function execute() {
69 $this->objectManager
= t3lib_div
::makeInstance('Tx_Extbase_Object_ObjectManager');
70 $this->commandManager
= $this->objectManager
->get('Tx_Extbase_MVC_CLI_CommandManager');
71 $this->taskExecutor
= $this->objectManager
->get('Tx_Extbase_Scheduler_TaskExecutor');
73 $this->taskExecutor
->execute($this);
75 } catch (Exception
$e) {
76 t3lib_div
::sysLog($e->getMessage(), $this->commandIdentifier
, 3);
82 * @param string $commandIdentifier
84 public function setCommandIdentifier($commandIdentifier) {
85 $this->commandIdentifier
= $commandIdentifier;
91 public function getCommandIdentifier() {
92 return $this->commandIdentifier
;
96 * @param array $arguments
98 public function setArguments($arguments) {
99 $this->arguments
= $arguments;
105 public function getArguments() {
106 return $this->arguments
;
110 * @param array $defaults
112 public function setDefaults(array $defaults) {
113 $this->defaults
= $defaults;
119 public function getDefaults() {
120 return $this->defaults
;
124 * @param string $argumentName
125 * @param mixed $argumentValue
127 public function addDefaultValue($argumentName, $argumentValue) {
128 if (is_bool($argumentValue)) {
129 $argumentValue = intval($argumentValue);
131 $this->defaults
[$argumentName] = $argumentValue;
135 * Return a text representation of the selected command and arguments
137 * @return string Information to display
139 public function getAdditionalInformation() {
140 $label = $this->commandIdentifier
;
141 if (count($this->arguments
) > 0) {
142 $arguments = array();
143 foreach ($this->arguments
as $argumentName=>$argumentValue) {
144 if ($argumentValue != $this->defaults
[$argumentName]) {
145 array_push($arguments, $argumentName . '=' . $argumentValue);
148 $label .= ' ' . implode(', ', $arguments);