1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-21 16:22:22 +02:00

[feature/system-cron] Add array type hints if appropriate and remove globals.

PHPBB3-9596
This commit is contained in:
Nils Adermann 2011-01-12 23:02:00 +01:00 committed by Oleg Pudeyev
parent 165b0ec0b2
commit 9bc62056b2
2 changed files with 23 additions and 12 deletions

View File

@ -30,7 +30,7 @@ function output_image()
echo base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
// test without flush ;)
// flush();
flush();
}
function do_cron($cron_lock, $run_tasks)

View File

@ -28,17 +28,30 @@ class phpbb_cron_manager
* Set of phpbb_cron_task_wrapper objects.
* Array holding all tasks that have been found.
*
* @var array
* @var array
*/
private $tasks = array();
protected $tasks = array();
/**
* phpBB's root directory.
* @var string
*/
protected $phpbb_root_path;
/**
* PHP file extension
* @var string
*/
protected $phpEx;
/**
* Constructor. Loads all available tasks.
*
* @return void
*/
public function __construct()
public function __construct($phpbb_root_path, $phpEx)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx;
$task_names = $this->find_cron_task_names();
$this->load_tasks($task_names);
}
@ -59,12 +72,10 @@ class phpbb_cron_manager
*/
public function find_cron_task_names()
{
global $phpbb_root_path, $phpEx;
$tasks_root_path = $phpbb_root_path . 'includes/cron/task/';
$tasks_root_path = $this->phpbb_root_path . 'includes/cron/task/';
$task_names = array();
$ext = '.' . $phpEx;
$ext = '.' . $this->phpEx;
$ext_length = strlen($ext);
$dh = opendir($tasks_root_path);
@ -115,7 +126,7 @@ class phpbb_cron_manager
*
* @return void
*/
public function load_tasks($task_names)
public function load_tasks(array $task_names)
{
foreach ($task_names as $task_name)
{
@ -196,7 +207,7 @@ class phpbb_cron_manager
*
* @return phpbb_cron_task_wrapper|null
*/
public function instantiate_task($name, $args)
public function instantiate_task($name, array $args)
{
$task = $this->find_task($name);
if ($task)