[ticket/546] Use phpbb\language\language for module language files
B3P-546
This commit is contained in:
@@ -34,6 +34,7 @@ services:
|
|||||||
- @auth
|
- @auth
|
||||||
- @board3.portal.columns
|
- @board3.portal.columns
|
||||||
- @config
|
- @config
|
||||||
|
- @language
|
||||||
- @template
|
- @template
|
||||||
- @user
|
- @user
|
||||||
- @path_helper
|
- @path_helper
|
||||||
|
|||||||
@@ -26,6 +26,9 @@ class helper
|
|||||||
*/
|
*/
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
|
/** @var \phpbb\language\language */
|
||||||
|
protected $language;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template object
|
* Template object
|
||||||
* @var \phpbb\template
|
* @var \phpbb\template
|
||||||
@@ -84,6 +87,7 @@ class helper
|
|||||||
* @param \phpbb\auth\auth $auth Auth object
|
* @param \phpbb\auth\auth $auth Auth object
|
||||||
* @param \board3\portal\portal\columns $portal_columns Board3 Portal columns object
|
* @param \board3\portal\portal\columns $portal_columns Board3 Portal columns object
|
||||||
* @param \phpbb\config\config $config phpBB Config object
|
* @param \phpbb\config\config $config phpBB Config object
|
||||||
|
* @param \phpbb\language\language $language phpBB language
|
||||||
* @param \phpbb\template $template Template object
|
* @param \phpbb\template $template Template object
|
||||||
* @param \phpbb\user $user User object
|
* @param \phpbb\user $user User object
|
||||||
* @param \phpbb\path_helper $path_helper phpBB path helper
|
* @param \phpbb\path_helper $path_helper phpBB path helper
|
||||||
@@ -91,11 +95,12 @@ class helper
|
|||||||
* @param string $phpbb_root_path phpBB root path
|
* @param string $phpbb_root_path phpBB root path
|
||||||
* @param string $php_ext PHP file extension
|
* @param string $php_ext PHP file extension
|
||||||
*/
|
*/
|
||||||
public function __construct($auth, $portal_columns, $config, $template, $user, $path_helper, $portal_helper, $phpbb_root_path, $php_ext)
|
public function __construct($auth, $portal_columns, $config, $language, $template, $user, $path_helper, $portal_helper, $phpbb_root_path, $php_ext)
|
||||||
{
|
{
|
||||||
$this->auth = $auth;
|
$this->auth = $auth;
|
||||||
$this->portal_columns = $portal_columns;
|
$this->portal_columns = $portal_columns;
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->language = $language;
|
||||||
$this->template = $template;
|
$this->template = $template;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->path_helper = $path_helper;
|
$this->path_helper = $path_helper;
|
||||||
@@ -204,11 +209,11 @@ class helper
|
|||||||
// Load language file from vendor if specified
|
// Load language file from vendor if specified
|
||||||
if (is_array($language_file))
|
if (is_array($language_file))
|
||||||
{
|
{
|
||||||
$this->user->add_lang_ext($language_file['vendor'], $language_file['file']);
|
$this->language->add_lang($language_file['file'], $language_file['vendor']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->user->add_lang_ext('board3/portal', 'modules/' . $language_file);
|
$this->language->add_lang('modules/' . $language_file, 'board3/portal');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,10 +101,14 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
$phpEx
|
$phpEx
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
|
||||||
$b3p_controller_helper = new \board3\portal\controller\helper(
|
$b3p_controller_helper = new \board3\portal\controller\helper(
|
||||||
new \phpbb\auth\auth(),
|
new \phpbb\auth\auth(),
|
||||||
$this->portal_columns,
|
$this->portal_columns,
|
||||||
$config,
|
$config,
|
||||||
|
$this->language,
|
||||||
$template,
|
$template,
|
||||||
$user,
|
$user,
|
||||||
$path_helper,
|
$path_helper,
|
||||||
@@ -130,6 +134,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
|||||||
$auth,
|
$auth,
|
||||||
$this->portal_columns,
|
$this->portal_columns,
|
||||||
$config,
|
$config,
|
||||||
|
$this->language,
|
||||||
$template,
|
$template,
|
||||||
$user,
|
$user,
|
||||||
$path_helper,
|
$path_helper,
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
namespace board3\portal\controller;
|
namespace board3\portal\controller;
|
||||||
|
|
||||||
|
require_once(__DIR__ . '/../../../includes/functions.php');
|
||||||
|
|
||||||
class helper_test extends \board3\portal\tests\testframework\test_case
|
class helper_test extends \board3\portal\tests\testframework\test_case
|
||||||
{
|
{
|
||||||
protected $controller_helper;
|
protected $controller_helper;
|
||||||
@@ -19,7 +21,7 @@ class helper_test extends \board3\portal\tests\testframework\test_case
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
global $cache, $phpbb_extension_manager;
|
global $cache, $phpbb_extension_manager, $phpbb_root_path;
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@@ -33,10 +35,13 @@ class helper_test extends \board3\portal\tests\testframework\test_case
|
|||||||
'board3_enable' => true,
|
'board3_enable' => true,
|
||||||
));
|
));
|
||||||
$this->template = new \board3\portal\tests\mock\template($this);
|
$this->template = new \board3\portal\tests\mock\template($this);
|
||||||
$this->user = new \phpbb\user('\phpbb\datetime');
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
$this->user = new \phpbb\user($this->language, '\phpbb\datetime');
|
||||||
$this->user->data['group_id'] = 2;
|
$this->user->data['group_id'] = 2;
|
||||||
$this->phpbb_root_path = dirname(__FILE__) . '/../../../../../../';
|
$this->phpbb_root_path = dirname(__FILE__) . '/../../../../../../';
|
||||||
$phpbb_extension_manager = new \phpbb_mock_extension_manager($this->phpbb_root_path, array('board3/portal'));
|
$phpbb_extension_manager = new \phpbb_mock_extension_manager($this->phpbb_root_path, array('board3/portal'));
|
||||||
|
$this->language_file_loader->set_extension_manager($phpbb_extension_manager);
|
||||||
$this->php_ext = 'php';
|
$this->php_ext = 'php';
|
||||||
$this->portal_columns = new \board3\portal\portal\columns();
|
$this->portal_columns = new \board3\portal\portal\columns();
|
||||||
$this->modules = array(
|
$this->modules = array(
|
||||||
@@ -61,6 +66,7 @@ class helper_test extends \board3\portal\tests\testframework\test_case
|
|||||||
$this->auth,
|
$this->auth,
|
||||||
$this->portal_columns,
|
$this->portal_columns,
|
||||||
$this->config,
|
$this->config,
|
||||||
|
$this->language,
|
||||||
$this->template,
|
$this->template,
|
||||||
$this->user,
|
$this->user,
|
||||||
$this->path_helper,
|
$this->path_helper,
|
||||||
|
|||||||
@@ -59,11 +59,14 @@ class main_test extends \board3\portal\tests\testframework\database_test_case
|
|||||||
->method('acl_get')
|
->method('acl_get')
|
||||||
->with($this->anything())
|
->with($this->anything())
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
|
||||||
$controller_helper = new \board3\portal\controller\helper(
|
$controller_helper = new \board3\portal\controller\helper(
|
||||||
$auth,
|
$auth,
|
||||||
$portal_columns,
|
$portal_columns,
|
||||||
$this->config,
|
$this->config,
|
||||||
|
$this->language,
|
||||||
$this->template,
|
$this->template,
|
||||||
$user,
|
$user,
|
||||||
$path_helper,
|
$path_helper,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class listener_test extends \phpbb_template_template_test_case
|
|||||||
|
|
||||||
public function setup_listener()
|
public function setup_listener()
|
||||||
{
|
{
|
||||||
global $cache, $db;
|
global $cache, $db, $phpbb_root_path;
|
||||||
|
|
||||||
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists', 'put', 'obtain_attach_extensions'));
|
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'get', 'sql_exists', 'put', 'obtain_attach_extensions'));
|
||||||
$cache->expects($this->any())
|
$cache->expects($this->any())
|
||||||
@@ -48,8 +48,10 @@ class listener_test extends \phpbb_template_template_test_case
|
|||||||
->with($this->anything())
|
->with($this->anything())
|
||||||
->will($this->returnValue(false));
|
->will($this->returnValue(false));
|
||||||
$db = $this->getMock('\phpbb\db\driver\driver_interface');
|
$db = $this->getMock('\phpbb\db\driver\driver_interface');
|
||||||
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
|
||||||
$this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
|
$this->user = $this->getMock('\phpbb\user', array(), array($this->language, '\phpbb\datetime'));
|
||||||
$this->user->expects($this->any())
|
$this->user->expects($this->any())
|
||||||
->method('lang')
|
->method('lang')
|
||||||
->will($this->returnValue('foo'));
|
->will($this->returnValue('foo'));
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ class phpbb_functions_fetch_news_test extends \board3\portal\tests\testframework
|
|||||||
|
|
||||||
global $auth, $cache, $phpbb_container, $phpbb_dispatcher, $template, $user, $phpbb_root_path, $phpEx;
|
global $auth, $cache, $phpbb_container, $phpbb_dispatcher, $template, $user, $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
$user = new \phpbb\user('\phpbb\datetime');
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
$user = new \phpbb\user($this->language, '\phpbb\datetime');
|
||||||
$user->data['user_id'] = 2;
|
$user->data['user_id'] = 2;
|
||||||
$user->timezone = new \DateTimeZone('UTC');
|
$user->timezone = new \DateTimeZone('UTC');
|
||||||
$user->add_lang('common');
|
$user->add_lang('common');
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ class phpbb_unit_functions_functions_test extends \board3\portal\tests\testframe
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
global $cache, $user;
|
global $cache, $user, $phpbb_root_path;
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$user = $this->getMock('\phpbb\user', array('optionget'), array('\phpbb\datetime'));
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
$user = $this->getMock('\phpbb\user', array('optionget'), array($this->language, '\phpbb\datetime'));
|
||||||
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'sql_exists'));
|
$cache = $this->getMock('\phpbb\cache\cache', array('obtain_word_list', 'sql_exists'));
|
||||||
$cache->expects($this->any())
|
$cache->expects($this->any())
|
||||||
->method('obtain_word_list')
|
->method('obtain_word_list')
|
||||||
|
|||||||
@@ -18,11 +18,13 @@ class phpbb_unit_functions_get_user_groups_test extends \board3\portal\tests\tes
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
global $cache, $user;
|
global $cache, $user, $phpbb_root_path;
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$user = $this->getMock('\phpbb\user', array('optionget'), array('\phpbb\datetime'));
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
$user = $this->getMock('\phpbb\user', array('optionget'), array($this->language, '\phpbb\datetime'));
|
||||||
$cache = $this->getMock('\phpbb\cache\cache', array('get', 'put', 'sql_exists'));
|
$cache = $this->getMock('\phpbb\cache\cache', array('get', 'put', 'sql_exists'));
|
||||||
$cache->expects($this->any())
|
$cache->expects($this->any())
|
||||||
->method('get')
|
->method('get')
|
||||||
|
|||||||
@@ -42,10 +42,14 @@ class phpbb_functions_version_check_test extends \board3\portal\tests\testframew
|
|||||||
|
|
||||||
protected function get_version_helper($version)
|
protected function get_version_helper($version)
|
||||||
{
|
{
|
||||||
|
global $phpbb_root_path;
|
||||||
|
|
||||||
$this->config->set('board3_portal_version', $version);
|
$this->config->set('board3_portal_version', $version);
|
||||||
|
|
||||||
$this->template = new \board3\portal\tests\mock\template($this);
|
$this->template = new \board3\portal\tests\mock\template($this);
|
||||||
$version_helper = new \phpbb\version_helper($this->cache, $this->config, new \phpbb\file_downloader(), new \phpbb\user('\phpbb\datetime'));
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
$version_helper = new \phpbb\version_helper($this->cache, $this->config, new \phpbb\file_downloader(), new \phpbb\user($this->language, '\phpbb\datetime'));
|
||||||
$this->version_check = new \board3\portal\includes\version_check($this->version_data, $this->config, $version_helper, $this->template, $this->user);
|
$this->version_check = new \board3\portal\includes\version_check($this->version_data, $this->config, $version_helper, $this->template, $this->user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,9 @@ class phpbb_portal_fetch_posts_test extends \board3\portal\tests\testframework\d
|
|||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$user = new \phpbb\user('\phpbb\datetime');
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
$user = new \phpbb\user($this->language, '\phpbb\datetime');
|
||||||
$user->data['user_id'] = 2;
|
$user->data['user_id'] = 2;
|
||||||
$user->timezone = new \DateTimeZone('UTC');
|
$user->timezone = new \DateTimeZone('UTC');
|
||||||
$user->add_lang('common');
|
$user->add_lang('common');
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class modules_manager_confirm_box_test extends \board3\portal\tests\testframewor
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
global $cache, $db, $portal_config;
|
global $cache, $db, $portal_config, $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@@ -95,10 +95,14 @@ class modules_manager_confirm_box_test extends \board3\portal\tests\testframewor
|
|||||||
$phpEx
|
$phpEx
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
|
||||||
$this->b3p_controller_helper = new \board3\portal\controller\helper(
|
$this->b3p_controller_helper = new \board3\portal\controller\helper(
|
||||||
new \phpbb\auth\auth(),
|
new \phpbb\auth\auth(),
|
||||||
$this->portal_columns,
|
$this->portal_columns,
|
||||||
$config,
|
$config,
|
||||||
|
$this->language,
|
||||||
new \board3\portal\tests\mock\template($this),
|
new \board3\portal\tests\mock\template($this),
|
||||||
$user,
|
$user,
|
||||||
$this->path_helper,
|
$this->path_helper,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class board3_portal_modules_manager_test extends \board3\portal\tests\testframew
|
|||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
global $cache, $db;
|
global $cache, $db, $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
@@ -90,10 +90,14 @@ class board3_portal_modules_manager_test extends \board3\portal\tests\testframew
|
|||||||
$phpEx
|
$phpEx
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
|
||||||
|
$this->language = new \phpbb\language\language($this->language_file_loader);
|
||||||
|
|
||||||
$this->b3p_controller_helper = new \board3\portal\controller\helper(
|
$this->b3p_controller_helper = new \board3\portal\controller\helper(
|
||||||
new \phpbb\auth\auth(),
|
new \phpbb\auth\auth(),
|
||||||
$this->portal_columns,
|
$this->portal_columns,
|
||||||
$config,
|
$config,
|
||||||
|
$this->language,
|
||||||
new \board3\portal\tests\mock\template($this),
|
new \board3\portal\tests\mock\template($this),
|
||||||
$user,
|
$user,
|
||||||
$this->path_helper,
|
$this->path_helper,
|
||||||
|
|||||||
Reference in New Issue
Block a user