phpbb/tests/notification/manager_helper.php
Nicofuma be0d4e20d4 [ticket/11444] Moving the in-board notifications to a method class
Currently the in-board method for the notifications is hardcoded and
cannot be disabled. This method should be in his own class extending
`phpbb\notification\method\method_interface`.

It also add the possibility, for each method, to be enabled by default (ie:
no entry in the DB => notification enabled).

https://tracker.phpbb.com/browse/PHPBB3-11444
https://tracker.phpbb.com/browse/PHPBB3-11967

PHPBB3-11444
2015-07-13 22:41:13 +02:00

77 lines
2 KiB
PHP

<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Notifications service class
*/
class phpbb_notification_manager_helper extends \phpbb\notification\manager
{
public function set_var($name, $value)
{
$this->$name = $value;
}
// Extra dependencies for get_*_class functions
protected $auth = null;
protected $config = null;
public function setDependencies($auth, $config)
{
$this->auth = $auth;
$this->config = $config;
}
/**
* Helper to get the notifications item type class and set it up
*/
public function get_item_type_class($item_type, $data = array())
{
$item_parts = explode('.', $item_type);
$item_type = 'phpbb\notification\type\\' . array_pop($item_parts);
$item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->user_notifications_table);
if ($item_type === 'phpbb\\notification\\type\\quote')
{
$item->set_utils(new \phpbb\textformatter\s9e\utils);
}
$item->set_notification_manager($this);
$item->set_initial_data($data);
return $item;
}
/**
* Helper to get the notifications method class and set it up
*/
public function get_method_class($method_name)
{
$method_parts = explode('.', $method_name);
$method_name = 'phpbb\notification\method\\' . array_pop($method_parts);
$method = new $method_name($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, NOTIFICATIONS_TABLE, $this->user_notifications_table);
$method->set_notification_manager($this);
return $method;
}
}