From 87bf71684d73d7baf6597b2178cf47665a6fb157 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 27 Jun 2014 17:38:43 +0200 Subject: [PATCH] [ticket/269] Move definition of portal tables to services file B3P-269 --- acp/portal_module.php | 4 +++- config/services.yml | 4 ++++ controller/main.php | 6 +++++- includes/constants.php | 9 --------- tests/unit/acp/move_module_test.php | 4 +++- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/acp/portal_module.php b/acp/portal_module.php index a135132a..92d4af41 100644 --- a/acp/portal_module.php +++ b/acp/portal_module.php @@ -23,7 +23,7 @@ class portal_module public function __construct() { - global $db, $user, $cache, $request, $template; + global $db, $user, $cache, $request, $template, $table_prefix; global $config, $phpbb_root_path, $phpbb_admin_path, $phpbb_container, $phpEx; $user->add_lang_ext('board3/portal', array('portal', 'portal_acp')); @@ -44,6 +44,8 @@ class portal_module $this->phpbb_container = $phpbb_container; $this->mod_version_check = $this->phpbb_container->get('board3.version.check'); $this->register_modules($this->phpbb_container->get('board3.module_collection')); + define('PORTAL_MODULES_TABLE', $this->phpbb_container->getParameter('board3.modules.table')); + define('PORTAL_CONFIG_TABLE', $this->phpbb_container->getParameter('board3.config.table')); if (!function_exists('column_string_const')) { diff --git a/config/services.yml b/config/services.yml index 94ba2650..a779c9b3 100644 --- a/config/services.yml +++ b/config/services.yml @@ -11,6 +11,8 @@ parameters: - board3.de - updatecheck - board3_portal.xml + board3.config.table: %core.table_prefix%portal_config + board3.modules.table: %core.table_prefix%portal_modules services: board3.portal.main: @@ -24,6 +26,8 @@ services: - %core.root_path% - .%core.php_ext% - @board3.module_collection + - %board3.config.table% + - %board3.modules.table% board3.version.check: class: board3\portal\includes\mod_version_check diff --git a/controller/main.php b/controller/main.php index d6072a96..abd02895 100644 --- a/controller/main.php +++ b/controller/main.php @@ -84,8 +84,10 @@ class main * @param string $php_ext PHP file extension * @param \phpbb\di\service_collection $modules Board3 Modules service * collection + * @param string $config_table Board3 config table + * @param string $modules_table Board3 modules table */ - public function __construct($auth, $config, $template, $user, $path_helper, $phpbb_root_path, $php_ext, $modules) + public function __construct($auth, $config, $template, $user, $path_helper, $phpbb_root_path, $php_ext, $modules, $config_table, $modules_table) { global $portal_root_path; @@ -101,6 +103,8 @@ class main $this->includes_path = $phpbb_root_path . 'ext/board3/portal/includes/'; $this->root_path = $phpbb_root_path . 'ext/board3/portal/'; $portal_root_path = $this->root_path; + define('PORTAL_MODULES_TABLE', $modules_table); + define('PORTAL_CONFIG_TABLE', $config_table); if (!function_exists('obtain_portal_config')) { diff --git a/includes/constants.php b/includes/constants.php index 4bdc73f1..e503e773 100644 --- a/includes/constants.php +++ b/includes/constants.php @@ -7,18 +7,9 @@ * */ -if (!defined('IN_PHPBB')) -{ - exit; -} - -global $table_prefix; - // Config constants define('B3_MODULE_DISABLED', 0); define('B3_MODULE_ENABLED', 1); // Tables and paths define('PORTAL_ROOT_PATH', 'portal/'); -define('PORTAL_MODULES_TABLE', $table_prefix . 'portal_modules'); -define('PORTAL_CONFIG_TABLE', $table_prefix . 'portal_config'); diff --git a/tests/unit/acp/move_module_test.php b/tests/unit/acp/move_module_test.php index 08cdbdaf..b9b118fa 100644 --- a/tests/unit/acp/move_module_test.php +++ b/tests/unit/acp/move_module_test.php @@ -21,7 +21,7 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data public function setUp() { parent::setUp(); - global $db, $cache, $phpbb_root_path, $phpEx, $user, $phpbb_container, $request, $template; + global $db, $cache, $phpbb_root_path, $phpEx, $user, $phpbb_container, $request, $template, $table_prefix; $user = new \board3\portal\tests\mock\user(); $phpbb_container = new \phpbb_mock_container_builder(); // Mock version check @@ -38,6 +38,8 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data new \board3\portal\modules\welcome($config, new \phpbb_mock_request, $this->db, $user, $phpbb_root_path, $phpEx), new \board3\portal\modules\donation($config, $template, $user), )); + $phpbb_container->setParameter('board3.modules.table', $table_prefix . 'portal_modules'); + $phpbb_container->setParameter('board3.config.table', $table_prefix . 'portal_config'); $cache = $this->getMock('\phpbb\cache\cache', array('destroy', 'sql_exists', 'get', 'put')); $cache->expects($this->any()) ->method('destroy')