From 2e76620c8824da62f97cfdaee8f9b1014159fd7c Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 9 Apr 2012 00:22:55 +0200 Subject: [feature/dic] Rewrite cron system to use DIC PHPBB3-10739 --- phpBB/includes/cron/manager.php | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'phpBB/includes/cron/manager.php') diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php index 7a78a1b054..5abbc987dd 100644 --- a/phpBB/includes/cron/manager.php +++ b/phpBB/includes/cron/manager.php @@ -35,26 +35,25 @@ class phpbb_cron_manager /** * Constructor. Loads all available tasks. * - * @param array|Traversable $task_names Provides an iterable set of task names + * @param array|Traversable $tasks Provides an iterable set of task names */ - public function __construct($task_names) + public function __construct($tasks) { - $this->load_tasks($task_names); + $this->load_tasks($tasks); } /** * Loads tasks given by name, wraps them * and puts them into $this->tasks. * - * @param array|Traversable $task_names Array of strings + * @param array|Traversable $tasks Array of instances of phpbb_cron_task * * @return void */ - public function load_tasks($task_names) + public function load_tasks($tasks) { - foreach ($task_names as $task_name) + foreach ($tasks as $task) { - $task = new $task_name(); $wrapper = new phpbb_cron_task_wrapper($task); $this->tasks[] = $wrapper; } @@ -120,27 +119,4 @@ class phpbb_cron_manager } return null; } - - /** - * Creates an instance of parametrized cron task $name with args $args. - * The constructed task is wrapped with cron task wrapper before being returned. - * - * @param string $name The task name, which is the same as cron task class name. - * @param array $args Will be passed to the task class's constructor. - * - * @return phpbb_cron_task_wrapper|null - */ - public function instantiate_task($name, array $args) - { - $task = $this->find_task($name); - if ($task) - { - // task here is actually an instance of cron task wrapper - $class = $task->get_name(); - $task = new $class($args); - // need to wrap the new task too - $task = new phpbb_cron_task_wrapper($task); - } - return $task; - } } -- cgit v1.2.1 From 3896ee953fbdb45d0485c0b5dcdfca47409a22ed Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Mon, 9 Apr 2012 14:34:35 +0200 Subject: [feature/dic] Give all cron tasks a name, change some manager usage PHPBB3-10739 --- phpBB/includes/cron/manager.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/cron/manager.php') diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php index 5abbc987dd..5ea909eb2c 100644 --- a/phpBB/includes/cron/manager.php +++ b/phpBB/includes/cron/manager.php @@ -32,13 +32,18 @@ class phpbb_cron_manager */ protected $tasks = array(); + protected $phpbb_root_path, $phpEx; + /** * Constructor. Loads all available tasks. * * @param array|Traversable $tasks Provides an iterable set of task names */ - public function __construct($tasks) + public function __construct($tasks, $phpbb_root_path, $phpEx) { + $this->phpbb_root_path = $phpbb_root_path; + $this->phpEx = $phpEx; + $this->load_tasks($tasks); } @@ -54,8 +59,7 @@ class phpbb_cron_manager { foreach ($tasks as $task) { - $wrapper = new phpbb_cron_task_wrapper($task); - $this->tasks[] = $wrapper; + $this->tasks[] = $this->wrap_task($task); } } @@ -119,4 +123,9 @@ class phpbb_cron_manager } return null; } + + public function wrap_task(phpbb_cron_task $task) + { + return new phpbb_cron_task_wrapper($task, $this->phpbb_root_path, $this->phpEx); + } } -- cgit v1.2.1 From 5cdcaaa5318c05a04c544eeb25ced571737c2ce3 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Thu, 26 Jul 2012 16:15:56 +0200 Subject: [feature/dic] Rename {phpEx => php_ext} for consistency PHPBB3-10739 --- phpBB/includes/cron/manager.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/cron/manager.php') diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php index 5ea909eb2c..018ae39f18 100644 --- a/phpBB/includes/cron/manager.php +++ b/phpBB/includes/cron/manager.php @@ -32,17 +32,17 @@ class phpbb_cron_manager */ protected $tasks = array(); - protected $phpbb_root_path, $phpEx; + protected $phpbb_root_path, $php_ext; /** * Constructor. Loads all available tasks. * * @param array|Traversable $tasks Provides an iterable set of task names */ - public function __construct($tasks, $phpbb_root_path, $phpEx) + public function __construct($tasks, $phpbb_root_path, $php_ext) { $this->phpbb_root_path = $phpbb_root_path; - $this->phpEx = $phpEx; + $this->php_ext = $php_ext; $this->load_tasks($tasks); } @@ -126,6 +126,6 @@ class phpbb_cron_manager public function wrap_task(phpbb_cron_task $task) { - return new phpbb_cron_task_wrapper($task, $this->phpbb_root_path, $this->phpEx); + return new phpbb_cron_task_wrapper($task, $this->phpbb_root_path, $this->php_ext); } } -- cgit v1.2.1 From 4f0f63ae8feb8efc70954e64bdca1f81ae98b212 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 25 Aug 2012 16:51:19 +0200 Subject: [feature/dic] Make cron task attributes protected, one per line PHPBB3-10739 --- phpBB/includes/cron/manager.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/cron/manager.php') diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php index 018ae39f18..7d2931b502 100644 --- a/phpBB/includes/cron/manager.php +++ b/phpBB/includes/cron/manager.php @@ -32,7 +32,8 @@ class phpbb_cron_manager */ protected $tasks = array(); - protected $phpbb_root_path, $php_ext; + protected $phpbb_root_path; + protected $php_ext; /** * Constructor. Loads all available tasks. -- cgit v1.2.1 From fd9fd71a88fad2b33d75722587dbfc0bd100ae50 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Sat, 25 Aug 2012 16:54:30 +0200 Subject: [feature/dic] Add docblock for cron_manager::wrap_task() PHPBB3-10739 --- phpBB/includes/cron/manager.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes/cron/manager.php') diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php index 7d2931b502..ccaa4f3764 100644 --- a/phpBB/includes/cron/manager.php +++ b/phpBB/includes/cron/manager.php @@ -125,6 +125,12 @@ class phpbb_cron_manager return null; } + /** + * Wraps a task inside an instance of phpbb_cron_task_wrapper. + * + * @param phpbb_cron_task $task The task. + * @return phpbb_cron_task_wrapper The wrapped task. + */ public function wrap_task(phpbb_cron_task $task) { return new phpbb_cron_task_wrapper($task, $this->phpbb_root_path, $this->php_ext); -- cgit v1.2.1 From ec4343c7447911c7e822a03c0f57fc2bb1c4ab3d Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Fri, 30 Nov 2012 23:03:06 -0500 Subject: [ticket/11227] @return void -> @return null, per coding guidelines. PHPBB3-11227 --- phpBB/includes/cron/manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/cron/manager.php') diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php index ccaa4f3764..84c9650830 100644 --- a/phpBB/includes/cron/manager.php +++ b/phpBB/includes/cron/manager.php @@ -54,7 +54,7 @@ class phpbb_cron_manager * * @param array|Traversable $tasks Array of instances of phpbb_cron_task * - * @return void + * @return null */ public function load_tasks($tasks) { -- cgit v1.2.1