1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/11444] Update tests and cleanup types/methods

PHPBB3-11444
This commit is contained in:
Tristan Darricau
2015-07-09 17:04:40 +02:00
parent f29b12e353
commit fc34057f28
18 changed files with 309 additions and 356 deletions

View File

@@ -26,7 +26,7 @@ class manager
/** @var array */
protected $subscription_types;
/** @var array */
/** @var method\method_interface[] */
protected $notification_methods;
/** @var ContainerInterface */
@@ -805,8 +805,10 @@ class manager
}
/**
* Helper to get the list of methods enabled by default
*/
* Helper to get the list of methods enabled by default
*
* @return method\method_interface[]
*/
public function get_default_methods()
{
$default_methods = array();
@@ -823,8 +825,10 @@ class manager
}
/**
* Helper to get the notifications item type class and set it up
*/
* Helper to get the notifications item type class and set it up
*
* @return type\type_interface
*/
public function get_item_type_class($notification_type_name, $data = array())
{
$item = $this->load_object($notification_type_name);
@@ -835,16 +839,20 @@ class manager
}
/**
* Helper to get the notifications method class and set it up
*/
* Helper to get the notifications method class and set it up
*
* @return method\method_interface
*/
public function get_method_class($method_name)
{
return $this->load_object($method_name);
}
/**
* Helper to load objects (notification types/methods)
*/
* Helper to load objects (notification types/methods)
*
* @return method\method_interface|type\type_interface
*/
protected function load_object($object_name)
{
$object = $this->phpbb_container->get($object_name);

View File

@@ -41,6 +41,22 @@ class admin_activate_user extends \phpbb\notification\type\base
'group' => 'NOTIFICATION_GROUP_ADMINISTRATION',
);
/** @var \phpbb\user_loader */
protected $user_loader;
/** @var \phpbb\config\config */
protected $config;
public function set_config(\phpbb\config\config $config)
{
$this->config = $config;
}
public function set_user_loader(\phpbb\user_loader $user_loader)
{
$this->user_loader = $user_loader;
}
/**
* {@inheritdoc}
*/

View File

@@ -21,36 +21,21 @@ abstract class base implements \phpbb\notification\type\type_interface
/** @var \phpbb\notification\manager */
protected $notification_manager;
/** @var \phpbb\user_loader */
protected $user_loader;
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/** @var \phpbb\cache\driver\driver_interface */
protected $cache;
/** @var \phpbb\template\template */
protected $template;
/** @var \phpbb\user */
protected $user;
/** @var \phpbb\auth\auth */
protected $auth;
/** @var \phpbb\config\config */
protected $config;
/** @var string */
protected $phpbb_root_path;
/** @var string */
protected $php_ext;
/** @var string */
protected $notification_types_table;
/** @var string */
protected $user_notifications_table;
@@ -88,31 +73,23 @@ abstract class base implements \phpbb\notification\type\type_interface
/**
* Notification Type Base Constructor
*
* @param \phpbb\user_loader $user_loader
* @param \phpbb\db\driver\driver_interface $db
* @param \phpbb\cache\driver\driver_interface $cache
* @param \phpbb\user $user
* @param \phpbb\auth\auth $auth
* @param \phpbb\config\config $config
* @param string $phpbb_root_path
* @param string $php_ext
* @param string $notification_types_table
* @param string $user_notifications_table
* @return \phpbb\notification\type\base
*/
public function __construct(\phpbb\user_loader $user_loader, \phpbb\db\driver\driver_interface $db, \phpbb\cache\driver\driver_interface $cache, $user, \phpbb\auth\auth $auth, \phpbb\config\config $config, $phpbb_root_path, $php_ext, $notification_types_table, $user_notifications_table)
public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\user $user, \phpbb\auth\auth $auth, $phpbb_root_path, $php_ext, $user_notifications_table)
{
$this->user_loader = $user_loader;
$this->db = $db;
$this->cache = $cache;
$this->user = $user;
$this->auth = $auth;
$this->config = $config;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->notification_types_table = $notification_types_table;
$this->user_notifications_table = $user_notifications_table;
}

View File

@@ -48,6 +48,14 @@ class bookmark extends \phpbb\notification\type\post
'group' => 'NOTIFICATION_GROUP_POSTING',
);
/** @var \phpbb\config\config */
protected $config;
public function set_config(\phpbb\config\config $config)
{
$this->config = $config;
}
/**
* Is available
*/
@@ -100,6 +108,7 @@ class bookmark extends \phpbb\notification\type\post
{
unset($notify_users[$user]);
/** @var bookmark $notification */
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data);
$update_responders = $notification->add_responders($post);
if (!empty($update_responders))

View File

@@ -30,6 +30,14 @@ class group_request extends \phpbb\notification\type\base
'lang' => 'NOTIFICATION_TYPE_GROUP_REQUEST',
);
/** @var \phpbb\user_loader */
protected $user_loader;
public function set_user_loader(\phpbb\user_loader $user_loader)
{
$this->user_loader = $user_loader;
}
/**
* {@inheritdoc}
*/

View File

@@ -40,6 +40,22 @@ class pm extends \phpbb\notification\type\base
'lang' => 'NOTIFICATION_TYPE_PM',
);
/** @var \phpbb\user_loader */
protected $user_loader;
/** @var \phpbb\config\config */
protected $config;
public function set_config(\phpbb\config\config $config)
{
$this->config = $config;
}
public function set_user_loader(\phpbb\user_loader $user_loader)
{
$this->user_loader = $user_loader;
}
/**
* Is available
*/

View File

@@ -55,6 +55,22 @@ class post extends \phpbb\notification\type\base
'group' => 'NOTIFICATION_GROUP_POSTING',
);
/** @var \phpbb\user_loader */
protected $user_loader;
/** @var \phpbb\config\config */
protected $config;
public function set_config(\phpbb\config\config $config)
{
$this->config = $config;
}
public function set_user_loader(\phpbb\user_loader $user_loader)
{
$this->user_loader = $user_loader;
}
/**
* Is available
*/
@@ -140,6 +156,7 @@ class post extends \phpbb\notification\type\base
{
unset($notify_users[$user]);
/** @var post $notification */
$notification = $this->notification_manager->get_item_type_class($this->get_type(), $notification_data);
$update_responders = $notification->add_responders($post);
if (!empty($update_responders))

View File

@@ -141,6 +141,8 @@ class report_pm extends \phpbb\notification\type\pm
*/
public function get_email_template_variables()
{
$user_data = $this->user_loader->get_username($this->get_data('reporter_id'), 'no_profile');
return array(
'AUTHOR_NAME' => htmlspecialchars_decode($user_data['username']),
'SUBJECT' => htmlspecialchars_decode(censor_text($this->get_data('message_subject'))),

View File

@@ -55,6 +55,22 @@ class topic extends \phpbb\notification\type\base
'group' => 'NOTIFICATION_GROUP_POSTING',
);
/** @var \phpbb\user_loader */
protected $user_loader;
/** @var \phpbb\config\config */
protected $config;
public function set_config(\phpbb\config\config $config)
{
$this->config = $config;
}
public function set_user_loader(\phpbb\user_loader $user_loader)
{
$this->user_loader = $user_loader;
}
/**
* Is available
*/