From 132d2c2bd85bac6ed87ea3c57de27a9675192f29 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Fri, 29 Oct 2010 11:40:18 +0200 Subject: [feature/system-cron] adjust some last filenames to make autoloading work PHPBB3-9596 --- phpBB/includes/cron/task/wrapper.php | 97 ++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 phpBB/includes/cron/task/wrapper.php (limited to 'phpBB/includes/cron/task/wrapper.php') diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/includes/cron/task/wrapper.php new file mode 100644 index 0000000000..e31f467cc8 --- /dev/null +++ b/phpBB/includes/cron/task/wrapper.php @@ -0,0 +1,97 @@ +task = $task; + } + + /** + * Returns whether this task is parametrized. + * + * Parametrized tasks accept parameters during initialization and must + * normally be scheduled with parameters. + */ + public function is_parametrized() + { + return $this->task instanceof phpbb_cron_task_parametrized; + } + + /** + * Returns whether the wrapped task is ready to run. + * + * A task is ready to run when it is runnable according to current configuration + * and enough time has passed since it was last run. + */ + public function is_ready() + { + return $this->task->is_runnable() && $this->task->should_run(); + } + + /** + * Returns the name of wrapped task. It is the same as the wrapped class's class name. + */ + public function get_name() + { + return get_class($this->task); + } + + /** + * Returns a url through which this task may be invoked via web. + */ + public function get_url() + { + global $phpbb_root_path, $phpEx; + + $name = $this->get_name(); + if ($this->is_parametrized()) + { + $params = $this->task->get_parameters(); + $extra = ''; + foreach ($params as $key => $value) + { + $extra .= '&' . $key . '=' . urlencode($value); + } + } + else + { + $extra = ''; + } + $url = append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $name . $extra); + return $url; + } + + /** + * Forwards all other method calls to the wrapped task implementation. + */ + public function __call($name, $args) + { + return call_user_func_array(array($this->task, $name), $args); + } +} -- cgit v1.2.1 From afc538366bc9660f9b7035e48034d1b7dccbd978 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 14 Dec 2010 13:20:54 +0100 Subject: [feature/system-cron] Remove $Id$ from PHP file header PHPBB3-9596 --- phpBB/includes/cron/task/wrapper.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes/cron/task/wrapper.php') diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/includes/cron/task/wrapper.php index e31f467cc8..c2e7e42830 100644 --- a/phpBB/includes/cron/task/wrapper.php +++ b/phpBB/includes/cron/task/wrapper.php @@ -2,7 +2,6 @@ /** * * @package phpBB3 -* @version $Id$ * @copyright (c) 2010 phpBB Group * @license http://opensource.org/licenses/gpl-license.php GNU Public License * -- cgit v1.2.1 From 47702b8ca72aeaa2b33dd13f2aa762ae7271c10a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 17 Dec 2010 01:24:27 +0100 Subject: [feature/system-cron] Add phpDoc documentation for everything else. PHPBB3-9596 --- phpBB/includes/cron/task/wrapper.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'phpBB/includes/cron/task/wrapper.php') diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/includes/cron/task/wrapper.php index c2e7e42830..23cd4de724 100644 --- a/phpBB/includes/cron/task/wrapper.php +++ b/phpBB/includes/cron/task/wrapper.php @@ -25,6 +25,8 @@ class phpbb_cron_task_wrapper { /** * Wraps a task $task, which must implement cron_task interface. + * + * @return void */ public function __construct(phpbb_cron_task $task) { @@ -36,6 +38,8 @@ class phpbb_cron_task_wrapper * * Parametrized tasks accept parameters during initialization and must * normally be scheduled with parameters. + * + * @return bool Whether or not this task is parametrized. */ public function is_parametrized() { @@ -47,6 +51,8 @@ class phpbb_cron_task_wrapper * * A task is ready to run when it is runnable according to current configuration * and enough time has passed since it was last run. + * + * @return bool Whether the wrapped task is ready to run. */ public function is_ready() { @@ -55,6 +61,8 @@ class phpbb_cron_task_wrapper /** * Returns the name of wrapped task. It is the same as the wrapped class's class name. + * + * @return string Class name of wrapped task. */ public function get_name() { @@ -63,6 +71,8 @@ class phpbb_cron_task_wrapper /** * Returns a url through which this task may be invoked via web. + * + * @return string URL */ public function get_url() { @@ -88,6 +98,8 @@ class phpbb_cron_task_wrapper /** * Forwards all other method calls to the wrapped task implementation. + * + * @return mixed */ public function __call($name, $args) { -- cgit v1.2.1 From 53dd847dd582930c84518d77a805468543e32ad0 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sun, 19 Dec 2010 23:56:43 +0100 Subject: [feature/system-cron] Added @param/@return documentation Also adjusted some function descriptions for greater informativity. PHPBB3-9596 --- phpBB/includes/cron/task/wrapper.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/cron/task/wrapper.php') diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/includes/cron/task/wrapper.php index 23cd4de724..238d97853c 100644 --- a/phpBB/includes/cron/task/wrapper.php +++ b/phpBB/includes/cron/task/wrapper.php @@ -24,9 +24,11 @@ if (!defined('IN_PHPBB')) class phpbb_cron_task_wrapper { /** + * Constructor. + * * Wraps a task $task, which must implement cron_task interface. * - * @return void + * @param phpbb_cron_task $task The cron task to wrap. */ public function __construct(phpbb_cron_task $task) { @@ -34,7 +36,7 @@ class phpbb_cron_task_wrapper } /** - * Returns whether this task is parametrized. + * Returns whether the wrapped task is parametrised. * * Parametrized tasks accept parameters during initialization and must * normally be scheduled with parameters. @@ -72,7 +74,11 @@ class phpbb_cron_task_wrapper /** * Returns a url through which this task may be invoked via web. * - * @return string URL + * When system cron is not in use, running a cron task is accomplished + * by outputting an image with the url returned by this function as + * source. + * + * @return string URL through which this task may be invoked. */ public function get_url() { -- cgit v1.2.1