mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 22:10:45 +02:00
[ticket/11103] Working on test case
Fixing extension type/method naming scheme so they can be autoloaded. Other bugs PHPBB3-11103
This commit is contained in:
@@ -466,11 +466,6 @@ class phpbb_notification_manager
|
||||
{
|
||||
$class_name = $this->get_item_type_class_name($class_name);
|
||||
|
||||
if (!class_exists($class_name))
|
||||
{
|
||||
include($file);
|
||||
}
|
||||
|
||||
$class = $this->get_item_type_class($class_name);
|
||||
|
||||
if ($class->is_available() && method_exists($class_name, 'get_item_type'))
|
||||
@@ -502,11 +497,6 @@ class phpbb_notification_manager
|
||||
{
|
||||
$class_name = 'phpbb_notification_method_' . $method_name;
|
||||
|
||||
if (!class_exists($class_name))
|
||||
{
|
||||
include($file);
|
||||
}
|
||||
|
||||
$method = $this->get_method_class($class_name);
|
||||
|
||||
if ($method->is_available())
|
||||
@@ -652,7 +642,14 @@ class phpbb_notification_manager
|
||||
{
|
||||
if (!$safe)
|
||||
{
|
||||
$item_type = preg_replace('#[^a-z_]#', '', $item_type);
|
||||
$item_type = preg_replace('#[^a-z_-]#', '', $item_type);
|
||||
}
|
||||
|
||||
if (strpos($item_type, 'ext_') === 0)
|
||||
{
|
||||
$item_type_ary = explode('-', substr($item_type, 4), 2);
|
||||
|
||||
return 'phpbb_ext_' . $item_type_ary[0] . '_notification_type_' . $item_type_ary[1];
|
||||
}
|
||||
|
||||
return 'phpbb_notification_type_' . $item_type;
|
||||
@@ -661,7 +658,7 @@ class phpbb_notification_manager
|
||||
/**
|
||||
* Helper to get the notifications item type class and set it up
|
||||
*/
|
||||
private function get_item_type_class($item_type, $data = array())
|
||||
public function get_item_type_class($item_type, $data = array())
|
||||
{
|
||||
$item = new $item_type($this, $this->db, $this->cache, $this->template, $this->extension_manager, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext);
|
||||
|
||||
@@ -673,7 +670,7 @@ class phpbb_notification_manager
|
||||
/**
|
||||
* Helper to get the notifications method class and set it up
|
||||
*/
|
||||
private function get_method_class($method_name)
|
||||
public function get_method_class($method_name)
|
||||
{
|
||||
return new $method_name($this, $this->db, $this->cache, $this->template, $this->extension_manager, $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext);
|
||||
}
|
||||
@@ -693,15 +690,23 @@ class phpbb_notification_manager
|
||||
->get_files();
|
||||
foreach ($files as $file)
|
||||
{
|
||||
$class = substr($file, strrpos($file, '/'));
|
||||
$class = substr($class, 1, (strpos($class, '.' . $this->php_ext) - 1));
|
||||
$name = substr($file, strrpos($file, '/'));
|
||||
$name = substr($name, 1, (strpos($name, '.' . $this->php_ext) - 1));
|
||||
|
||||
if ($class == 'interface' || $class == 'base')
|
||||
if ($name == 'interface' || $name == 'base')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$subscription_files[$class] = $file;
|
||||
if (!strpos($file, 'includes/')) // is an extension
|
||||
{
|
||||
$ext_name = substr($file, (strpos($file, 'ext/') + 4));
|
||||
$ext_name = substr($ext_name, 0, strpos($ext_name, '/'));
|
||||
|
||||
$name = 'ext_' . $ext_name . '-' . $name;
|
||||
}
|
||||
|
||||
$subscription_files[$name] = $file;
|
||||
}
|
||||
|
||||
return $subscription_files;
|
||||
|
@@ -50,7 +50,7 @@ abstract class phpbb_notification_method_base implements phpbb_notification_meth
|
||||
*/
|
||||
protected $queue = array();
|
||||
|
||||
public function __construct(phpbb_notification_manager $notification_manager, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, phpbb_user $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
|
||||
public function __construct(phpbb_notification_manager $notification_manager, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->notification_manager = $notification_manager;
|
||||
$this->db = $db;
|
||||
|
@@ -55,7 +55,7 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
|
||||
*/
|
||||
private $data = array();
|
||||
|
||||
public function __construct(phpbb_notification_manager $notification_manager, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, phpbb_user $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
|
||||
public function __construct(phpbb_notification_manager $notification_manager, dbal $db, phpbb_cache_driver_interface $cache, phpbb_template $template, phpbb_extension_manager $extension_manager, $user, phpbb_auth $auth, phpbb_config $config, $phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->notification_manager = $notification_manager;
|
||||
$this->db = $db;
|
||||
@@ -91,6 +91,11 @@ abstract class phpbb_notification_type_base implements phpbb_notification_type_i
|
||||
$this->data[$name] = $value;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return (!empty($this->data)) ? var_export($this->data, true) : static::get_item_type();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get special data (only important for the classes that extend this)
|
||||
*
|
||||
|
@@ -43,6 +43,8 @@ interface phpbb_notification_type_interface
|
||||
|
||||
public function create_insert_array($type_data);
|
||||
|
||||
public function users_to_query();
|
||||
|
||||
public function get_load_special();
|
||||
|
||||
public function load_special($data, $notifications);
|
||||
|
Reference in New Issue
Block a user