Merge pull request #529 from marc1706/ticket/528

[ticket/528] Correctly load module language for 3rd party modules
This commit is contained in:
Marc Alexander
2015-04-27 19:18:51 +02:00
5 changed files with 84 additions and 8 deletions

View File

@@ -103,6 +103,7 @@ services:
arguments:
- @cache
- @dbal.conn
- @board3.portal.controller_helper
- @board3.portal.columns
- @board3.portal.helper
- @board3.portal.modules.constraints_handler

View File

@@ -20,6 +20,9 @@ class manager
/** @var \phpbb\cache\service */
protected $cache;
/** @var \board3\portal\controller\helper */
protected $controller_helper;
/** @var \board3\portal\portal\columns */
protected $portal_columns;
@@ -55,6 +58,7 @@ class manager
*
* @param \phpbb\cache\service $cache phpBB cache
* @param \phpbb\db\driver\driver_interface $db Database driver
* @param \board3\portal\controller\helper $controller_helper Board3 Portal controller helper
* @param \board3\portal\portal\columns $portal_columns Portal columns helper
* @param \board3\portal\includes\helper $portal_helper Portal helper
* @param \board3\portal\portal\modules\constraints_handler $constraints_handler Modules constraints handler
@@ -62,10 +66,11 @@ class manager
* @param \phpbb\request\request_interface $request phpBB request
* @param \phpbb\user $user phpBB user
*/
public function __construct($cache, driver_interface $db, columns $portal_columns, helper $portal_helper, constraints_handler $constraints_handler, database_handler $database_handler, request_interface $request, $user)
public function __construct($cache, driver_interface $db, \board3\portal\controller\helper $controller_helper, columns $portal_columns, helper $portal_helper, constraints_handler $constraints_handler, database_handler $database_handler, request_interface $request, $user)
{
$this->cache = $cache;
$this->db = $db;
$this->controller_helper = $controller_helper;
$this->portal_columns = $portal_columns;
$this->portal_helper = $portal_helper;
$this->constraints_handler = $constraints_handler;
@@ -362,7 +367,7 @@ class manager
{
if ($this->module->get_language())
{
$this->user->add_lang_ext('board3/portal', 'modules/' . $this->module->get_language());
$this->controller_helper->load_module_language($this->module);
}
$confirm_text = (isset($this->user->lang[$module_data['module_name']])) ? sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], $this->user->lang[$module_data['module_name']]) : sprintf($this->user->lang['DELETE_MODULE_CONFIRM'], utf8_normalize_nfc($module_data['module_name']));
confirm_box(false, $confirm_text, build_hidden_fields(array(

View File

@@ -90,9 +90,6 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
));
$this->database_handler = new \board3\portal\portal\modules\database_handler($db);
$this->constraints_handler = new \board3\portal\portal\modules\constraints_handler($this->portal_columns, $user);
$this->modules_manager = new \board3\portal\portal\modules\manager($cache, $db, $this->portal_columns, $this->portal_helper, $this->constraints_handler, $this->database_handler, $request, $user);
$phpbb_container->set('board3.portal.modules.manager', $this->modules_manager);
$phpbb_container->set('board3.portal.modules.constraints_handler', $this->constraints_handler);
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
@@ -104,6 +101,21 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
$phpEx
);
$b3p_controller_helper = new \board3\portal\controller\helper(
new \phpbb\auth\auth(),
$this->portal_columns,
$config,
$template,
$user,
$path_helper,
$this->portal_helper,
$phpbb_root_path,
$phpEx
);
$this->modules_manager = new \board3\portal\portal\modules\manager($cache, $db, $b3p_controller_helper, $this->portal_columns, $this->portal_helper, $this->constraints_handler, $this->database_handler, $request, $user);
$phpbb_container->set('board3.portal.modules.manager', $this->modules_manager);
$phpbb_container->set('board3.portal.modules.constraints_handler', $this->constraints_handler);
$modules = array(
'\board3\portal\modules\clock' => new \board3\portal\modules\clock($config, $template),
);

View File

@@ -26,6 +26,12 @@ class modules_manager_confirm_box_test extends \board3\portal\tests\testframewor
/** @var \board3\portal\portal\modules\constraints_handler */
protected $constraints_handler;
/** @var \phpbb\path_helper */
protected $path_helper;
/** @var \board3\portal\controller\helper */
protected $b3p_controller_helper;
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/../acp/fixtures/modules.xml');
@@ -78,7 +84,30 @@ class modules_manager_confirm_box_test extends \board3\portal\tests\testframewor
$this->database_handler = new \board3\portal\portal\modules\database_handler($db);
$this->constraints_handler = new \board3\portal\portal\modules\constraints_handler($this->portal_columns, $user);
$this->modules_manager = new \board3\portal\portal\modules\manager($this->cache, $db, $this->portal_columns, $this->portal_helper, $this->constraints_handler, $this->database_handler, $request, $user);
$this->path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new \phpbb_mock_request()
),
new \phpbb\filesystem(),
new \phpbb_mock_request(),
$phpbb_root_path,
$phpEx
);
$this->b3p_controller_helper = new \board3\portal\controller\helper(
new \phpbb\auth\auth(),
$this->portal_columns,
$config,
new \board3\portal\tests\mock\template($this),
$user,
$this->path_helper,
$this->portal_helper,
$phpbb_root_path,
$phpEx
);
$this->modules_manager = new \board3\portal\portal\modules\manager($this->cache, $db, $this->b3p_controller_helper, $this->portal_columns, $this->portal_helper, $this->constraints_handler, $this->database_handler, $request, $user);
$portal_config = array();
}
@@ -126,7 +155,7 @@ class modules_manager_confirm_box_test extends \board3\portal\tests\testframewor
$this->cache->expects($this->any())
->method('purge');
$this->request->overwrite('module_classname', '\board3\portal\modules\donation');
$this->modules_manager = new \board3\portal\portal\modules\manager($this->cache, $this->db, $this->portal_columns, $this->portal_helper, $this->constraints_handler, $this->database_handler, $this->request, $this->user);
$this->modules_manager = new \board3\portal\portal\modules\manager($this->cache, $this->db, $this->b3p_controller_helper, $this->portal_columns, $this->portal_helper, $this->constraints_handler, $this->database_handler, $this->request, $this->user);
$this->modules_manager->set_u_action('adm/index.php?i=15&mode=foobar')->set_acp_class('foo\bar');
// Trigger confirm box creation

View File

@@ -20,6 +20,12 @@ class board3_portal_modules_manager_test extends \board3\portal\tests\testframew
/** @var \board3\portal\portal\modules\constraints_handler */
protected $constraints_handler;
/** @var \phpbb\path_helper */
protected $path_helper;
/** @var \board3\portal\controller\helper */
protected $b3p_controller_helper;
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/../acp/fixtures/modules.xml');
@@ -73,7 +79,30 @@ class board3_portal_modules_manager_test extends \board3\portal\tests\testframew
));
$this->database_handler = new \board3\portal\portal\modules\database_handler($db);
$this->constraints_handler = new \board3\portal\portal\modules\constraints_handler($this->portal_columns, $user);
$this->modules_manager = new \board3\portal\portal\modules\manager($cache, $db, $this->portal_columns, $portal_helper, $this->constraints_handler, $this->database_handler, $request, $user);
$this->path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new \phpbb_mock_request()
),
new \phpbb\filesystem(),
new \phpbb_mock_request(),
$phpbb_root_path,
$phpEx
);
$this->b3p_controller_helper = new \board3\portal\controller\helper(
new \phpbb\auth\auth(),
$this->portal_columns,
$config,
new \board3\portal\tests\mock\template($this),
$user,
$this->path_helper,
$this->portal_helper,
$phpbb_root_path,
$phpEx
);
$this->modules_manager = new \board3\portal\portal\modules\manager($cache, $db, $this->b3p_controller_helper, $this->portal_columns, $portal_helper, $this->constraints_handler, $this->database_handler, $request, $user);
$portal_modules = obtain_portal_modules();
foreach($portal_modules as $cur_module)
{