[ticket/416] Add modules database handler
B3P-416
This commit is contained in:
@@ -103,5 +103,11 @@ services:
|
||||
- @dbal.conn
|
||||
- @board3.portal.columns
|
||||
- @board3.portal.helper
|
||||
- @board.portal.modules.database_handler
|
||||
- @request
|
||||
- @user
|
||||
|
||||
board.portal.modules.database_handler:
|
||||
class: board3\portal\portal\modules\database_handler
|
||||
arguments:
|
||||
- @dbal.conn
|
||||
|
||||
47
portal/modules/database_handler.php
Normal file
47
portal/modules/database_handler.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package Board3 Portal v2.1
|
||||
* @copyright (c) 2014 Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
namespace board3\portal\portal\modules;
|
||||
|
||||
use phpbb\db\driver\driver_interface;
|
||||
|
||||
class database_handler
|
||||
{
|
||||
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* Constructor for modules manager
|
||||
*
|
||||
* @param \phpbb\db\driver\driver_interface $db Database driver
|
||||
*/
|
||||
public function __construct(driver_interface $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get module data from database
|
||||
*
|
||||
* @param int $module_id Module ID
|
||||
* @return array Module data array
|
||||
*/
|
||||
public function get_module_data($module_id)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . PORTAL_MODULES_TABLE . '
|
||||
WHERE module_id = ' . (int) $module_id;
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$module_data = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $module_data;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,9 @@ class manager
|
||||
/** @var \board3\portal\includes\helper */
|
||||
protected $portal_helper;
|
||||
|
||||
/** @var \board3\portal\portal\modules\database_handler */
|
||||
protected $database_handler;
|
||||
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
@@ -53,15 +56,17 @@ class manager
|
||||
* @param \phpbb\db\driver\driver_interface $db Database driver
|
||||
* @param \board3\portal\portal\columns $portal_columns Portal columns helper
|
||||
* @param \board3\portal\includes\helper $portal_helper Portal helper
|
||||
* @param \board3\portal\portal\modules\database_handler $database_handler Modules database handler
|
||||
* @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, request_interface $request, $user)
|
||||
public function __construct($cache, driver_interface $db, columns $portal_columns, helper $portal_helper, database_handler $database_handler, request_interface $request, $user)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
$this->db = $db;
|
||||
$this->portal_columns = $portal_columns;
|
||||
$this->portal_helper = $portal_helper;
|
||||
$this->database_handler = $database_handler;
|
||||
$this->request = $request;
|
||||
$this->user = $user;
|
||||
}
|
||||
@@ -176,14 +181,7 @@ class manager
|
||||
*/
|
||||
public function get_move_module_data($module_id)
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM ' . PORTAL_MODULES_TABLE . '
|
||||
WHERE module_id = ' . (int) $module_id;
|
||||
$result = $this->db->sql_query_limit($sql, 1);
|
||||
$module_data = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $module_data;
|
||||
return $this->database_handler->get_module_data($module_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,7 +71,8 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data
|
||||
'UNABLE_TO_MOVE' => 'UNABLE_TO_MOVE',
|
||||
'UNABLE_TO_MOVE_ROW' => 'UNABLE_TO_MOVE_ROW',
|
||||
));
|
||||
$this->modules_manager = new \board3\portal\portal\modules\manager($cache, $db, $this->portal_columns, $portal_helper, $request, $user);
|
||||
$this->database_handler = new \board3\portal\portal\modules\database_handler($db);
|
||||
$this->modules_manager = new \board3\portal\portal\modules\manager($cache, $db, $this->portal_columns, $portal_helper, $this->database_handler, $request, $user);
|
||||
$phpbb_container->set('board3.portal.modules.manager', $this->modules_manager);
|
||||
$this->portal_module = new \board3\portal\acp\portal_module();
|
||||
$this->update_portal_modules();
|
||||
|
||||
Reference in New Issue
Block a user