diff options
author | Máté Bartus <mate.bartus@gmail.com> | 2016-03-18 22:57:02 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2019-05-06 21:45:15 +0200 |
commit | 7a173877b7244f4ab6a8ff7b6fa0d6450027751b (patch) | |
tree | 5f820d58f33a9e972815007dfc79494669d7e702 /phpBB/phpbb/cron/task/wrapper.php | |
parent | 41956a8b9050fa6e1e301bfae51d947e6f13c068 (diff) | |
download | forums-7a173877b7244f4ab6a8ff7b6fa0d6450027751b.tar forums-7a173877b7244f4ab6a8ff7b6fa0d6450027751b.tar.gz forums-7a173877b7244f4ab6a8ff7b6fa0d6450027751b.tar.bz2 forums-7a173877b7244f4ab6a8ff7b6fa0d6450027751b.tar.xz forums-7a173877b7244f4ab6a8ff7b6fa0d6450027751b.zip |
[ticket/14542] Move cron to controller
PHPBB3-14542
Diffstat (limited to 'phpBB/phpbb/cron/task/wrapper.php')
-rw-r--r-- | phpBB/phpbb/cron/task/wrapper.php | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/phpBB/phpbb/cron/task/wrapper.php b/phpBB/phpbb/cron/task/wrapper.php index 8a4a8b1f0c..4dc3a7fb95 100644 --- a/phpBB/phpbb/cron/task/wrapper.php +++ b/phpBB/phpbb/cron/task/wrapper.php @@ -13,14 +13,32 @@ namespace phpbb\cron\task; +use phpbb\routing\helper; + /** * Cron task wrapper class. * Enhances cron tasks with convenience methods that work identically for all tasks. */ class wrapper { + /** + * @var helper + */ + protected $routing_helper; + + /** + * @var task + */ protected $task; + + /** + * @var string + */ protected $phpbb_root_path; + + /** + * @var string + */ protected $php_ext; /** @@ -28,13 +46,15 @@ class wrapper * * Wraps a task $task, which must implement cron_task interface. * - * @param \phpbb\cron\task\task $task The cron task to wrap. - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $php_ext PHP file extension + * @param task $task The cron task to wrap. + * @param helper $routing_helper Routing helper for route generation + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $php_ext PHP file extension */ - public function __construct(\phpbb\cron\task\task $task, $phpbb_root_path, $php_ext) + public function __construct(task $task, helper $routing_helper, $phpbb_root_path, $php_ext) { $this->task = $task; + $this->routing_helper = $routing_helper; $this->phpbb_root_path = $phpbb_root_path; $this->php_ext = $php_ext; } @@ -49,7 +69,7 @@ class wrapper */ public function is_parametrized() { - return $this->task instanceof \phpbb\cron\task\parametrized; + return $this->task instanceof parametrized; } /** @@ -76,22 +96,13 @@ class wrapper */ public function get_url() { - $name = $this->get_name(); + $params['cron_type'] = $this->get_name(); if ($this->is_parametrized()) { - $params = $this->task->get_parameters(); - $extra = ''; - foreach ($params as $key => $value) - { - $extra .= '&' . $key . '=' . urlencode($value); - } + $params = array_merge($params, $this->task->get_parameters()); } - else - { - $extra = ''; - } - $url = append_sid($this->phpbb_root_path . 'cron.' . $this->php_ext, 'cron_type=' . $name . $extra); - return $url; + + return $this->routing_helper->route('phpbb_cron_run', $params); } /** |