commandIdentifier = $commandIdentifier; } /** * @return string */ public function getCommandIdentifier(): string { return $this->commandIdentifier; } /** * This is the main method that is called when a task is executed * It MUST be implemented by all classes inheriting from this one * Note that there is no error handling, errors and failures are expected * to be handled and logged by the client implementations. * Should return TRUE on successful execution, FALSE on error. * * @throws \Exception * * @return bool Returns TRUE on successful execution, FALSE on error */ public function execute(): bool { try { $commandRegistry = GeneralUtility::makeInstance(CommandRegistry::class); $schedulableCommand = $commandRegistry->getCommandByIdentifier($this->commandIdentifier); } catch (UnknownCommandException $e) { throw new \RuntimeException( sprintf( $this->getLanguageService()->sL('LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:msg.unregisteredCommand'), $this->commandIdentifier ), 1505055445, $e ); } $input = new ArrayInput($this->getArguments(), $schedulableCommand->getDefinition()); $output = new NullOutput(); return $schedulableCommand->run($input, $output) === 0; } /** * @return array */ public function getArguments(): array { return $this->arguments; } /** * @param array $arguments */ public function setArguments(array $arguments) { $this->arguments = $arguments; } /** * @param string $argumentName * @param mixed $argumentValue */ public function addDefaultValue(string $argumentName, $argumentValue) { if (is_bool($argumentValue)) { $argumentValue = (int)$argumentValue; } $this->defaults[$argumentName] = $argumentValue; } /** * @return LanguageService */ public function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } }