[ Index ] |
PHP Cross Reference of phpBB-3.3.2-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 14 namespace phpbb\cron\task; 15 16 use phpbb\routing\helper; 17 18 /** 19 * Cron task wrapper class. 20 * Enhances cron tasks with convenience methods that work identically for all tasks. 21 */ 22 class wrapper 23 { 24 /** 25 * @var helper 26 */ 27 protected $routing_helper; 28 29 /** 30 * @var task 31 */ 32 protected $task; 33 34 /** 35 * @var string 36 */ 37 protected $phpbb_root_path; 38 39 /** 40 * @var string 41 */ 42 protected $php_ext; 43 44 /** 45 * Constructor. 46 * 47 * Wraps a task $task, which must implement cron_task interface. 48 * 49 * @param task $task The cron task to wrap. 50 * @param helper $routing_helper Routing helper for route generation 51 * @param string $phpbb_root_path Relative path to phpBB root 52 * @param string $php_ext PHP file extension 53 */ 54 public function __construct(task $task, helper $routing_helper, $phpbb_root_path, $php_ext) 55 { 56 $this->task = $task; 57 $this->routing_helper = $routing_helper; 58 $this->phpbb_root_path = $phpbb_root_path; 59 $this->php_ext = $php_ext; 60 } 61 62 /** 63 * Returns whether the wrapped task is parametrised. 64 * 65 * Parametrized tasks accept parameters during initialization and must 66 * normally be scheduled with parameters. 67 * 68 * @return bool Whether or not this task is parametrized. 69 */ 70 public function is_parametrized() 71 { 72 return $this->task instanceof parametrized; 73 } 74 75 /** 76 * Returns whether the wrapped task is ready to run. 77 * 78 * A task is ready to run when it is runnable according to current configuration 79 * and enough time has passed since it was last run. 80 * 81 * @return bool Whether the wrapped task is ready to run. 82 */ 83 public function is_ready() 84 { 85 return $this->task->is_runnable() && $this->task->should_run(); 86 } 87 88 /** 89 * Returns a url through which this task may be invoked via web. 90 * 91 * When system cron is not in use, running a cron task is accomplished 92 * by outputting an image with the url returned by this function as 93 * source. 94 * 95 * @return string URL through which this task may be invoked. 96 */ 97 public function get_url() 98 { 99 $params['cron_type'] = $this->get_name(); 100 if ($this->is_parametrized()) 101 { 102 $params = array_merge($params, $this->task->get_parameters()); 103 } 104 105 return $this->routing_helper->route('phpbb_cron_run', $params); 106 } 107 108 /** 109 * Forwards all other method calls to the wrapped task implementation. 110 * 111 * @return mixed 112 */ 113 public function __call($name, $args) 114 { 115 return call_user_func_array(array($this->task, $name), $args); 116 } 117 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:28:18 2020 | Cross-referenced by PHPXref 0.7.1 |