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