blob: 4f0f225e9163f3e1829a7eb5376e34cb6ea60420 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<?php
/**
*
* @package phpBB3
* @copyright (c) 2014 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace phpbb\console\command\cron;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class execute_all extends \phpbb\console\command\command
{
/** @var \phpbb\cron\manager */
protected $cron_manager;
/** @var \phpbb\lock\db */
protected $lock_db;
/** @var \phpbb\user */
protected $user;
public function __construct(\phpbb\cron\manager $cron_manager, \phpbb\lock\db $lock_db, \phpbb\user $user)
{
$this->cron_manager = $cron_manager;
$this->lock_db = $lock_db;
$this->user = $user;
parent::__construct();
}
protected function configure()
{
$this
->setName('cron:execute-all')
->setDescription($this->user->lang('CLI_DESCR_CRON_EXECUTE_ALL'))
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($this->lock_db->acquire())
{
$run_tasks = $this->cron_manager->find_all_ready_tasks();
foreach ($run_tasks as $task)
{
if ($input->getOption('verbose'))
{
$output->writeln($this->user->lang('RUNNING_TASK', $task->get_name()) . "\n");
}
$task->run();
}
$this->lock_db->release();
}
else
{
$output->writeln('<error>' . $this->user->lang('CRON_LOCK_ERROR') . '</error>');
}
}
}
|