[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * @license GNU General Public License, version 2 (GPL-2.0) 8 * 9 * For full copyright and license information, please see 10 * the docs/CREDITS.txt file. 11 * 12 */ 13 namespace phpbb\console\command\cron; 14 15 use Symfony\Component\Console\Input\InputInterface; 16 use Symfony\Component\Console\Output\OutputInterface; 17 18 class cron_list extends \phpbb\console\command\command 19 { 20 /** @var \phpbb\cron\manager */ 21 protected $cron_manager; 22 23 /** 24 * Constructor 25 * 26 * @param \phpbb\user $user User instance 27 * @param \phpbb\cron\manager $cron_manager Cron manager 28 */ 29 public function __construct(\phpbb\user $user, \phpbb\cron\manager $cron_manager) 30 { 31 $this->cron_manager = $cron_manager; 32 parent::__construct($user); 33 } 34 35 /** 36 * {@inheritdoc} 37 */ 38 protected function configure() 39 { 40 $this 41 ->setName('cron:list') 42 ->setDescription($this->user->lang('CLI_DESCRIPTION_CRON_LIST')) 43 ; 44 } 45 46 /** 47 * Executes the command cron:list. 48 * 49 * Prints a list of ready and unready cron jobs. 50 * 51 * @param InputInterface $input An InputInterface instance 52 * @param OutputInterface $output An OutputInterface instance 53 * 54 * @return null 55 */ 56 protected function execute(InputInterface $input, OutputInterface $output) 57 { 58 $tasks = $this->cron_manager->get_tasks(); 59 60 if (empty($tasks)) 61 { 62 $output->writeln($this->user->lang('CRON_NO_TASKS')); 63 return; 64 } 65 66 $ready_tasks = array(); 67 $not_ready_tasks = array(); 68 foreach ($tasks as $task) 69 { 70 if ($task->is_ready()) 71 { 72 $ready_tasks[] = $task; 73 } 74 else 75 { 76 $not_ready_tasks[] = $task; 77 } 78 } 79 80 if (!empty($ready_tasks)) 81 { 82 $output->writeln('<info>' . $this->user->lang('TASKS_READY') . '</info>'); 83 $this->print_tasks_names($ready_tasks, $output); 84 } 85 86 if (!empty($ready_tasks) && !empty($not_ready_tasks)) 87 { 88 $output->writeln(''); 89 } 90 91 if (!empty($not_ready_tasks)) 92 { 93 $output->writeln('<info>' . $this->user->lang('TASKS_NOT_READY') . '</info>'); 94 $this->print_tasks_names($not_ready_tasks, $output); 95 } 96 } 97 98 /** 99 * Print a list of cron jobs 100 * 101 * @param array $tasks A list of task to display 102 * @param OutputInterface $output An OutputInterface instance 103 */ 104 protected function print_tasks_names(array $tasks, OutputInterface $output) 105 { 106 foreach ($tasks as $task) 107 { 108 $output->writeln($task->get_name()); 109 } 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |