mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-16 14:33:14 +00:00
add return value for console commands
This commit is contained in:
@@ -45,9 +45,10 @@ class module_console_taskrun extends Command
|
||||
|
||||
public function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if(!setup::is_installed())
|
||||
if (!setup::is_installed())
|
||||
{
|
||||
throw new RuntimeException('Phraseanet is not set up');
|
||||
$output->writeln('Phraseanet is not set up');
|
||||
return 1;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../../../../lib/bootstrap.php';
|
||||
@@ -55,20 +56,32 @@ class module_console_taskrun extends Command
|
||||
$task_id = (int) $input->getArgument('task_id');
|
||||
|
||||
if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id')))
|
||||
throw new \RuntimeException('Argument must be an Id.');
|
||||
{
|
||||
$output->writeln('Argument must be an Id.');
|
||||
return 1;
|
||||
}
|
||||
|
||||
$appbox = appbox::get_instance();
|
||||
$task_manager = new task_manager($appbox);
|
||||
$task = $task_manager->get_task($task_id);
|
||||
try
|
||||
{
|
||||
$appbox = appbox::get_instance();
|
||||
$task_manager = new task_manager($appbox);
|
||||
$task = $task_manager->get_task($task_id);
|
||||
|
||||
$runner = task_abstract::RUNNER_SCHEDULER;
|
||||
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL)
|
||||
$runner = task_abstract::RUNNER_MANUAL;
|
||||
$runner = task_abstract::RUNNER_SCHEDULER;
|
||||
|
||||
$task->run($runner);
|
||||
|
||||
return $this;
|
||||
if ($input->getOption('runner') === task_abstract::RUNNER_MANUAL)
|
||||
{
|
||||
$runner = task_abstract::RUNNER_MANUAL;
|
||||
}
|
||||
|
||||
$task->run($runner);
|
||||
|
||||
return 0;
|
||||
}
|
||||
catch (\exception $e)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user