1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-28 10:40:28 +02:00

[ticket/11700] Move all recent code to namespaces

PHPBB3-11700
This commit is contained in:
Nils Adermann
2013-09-10 14:01:09 +02:00
parent 196e1813cd
commit b95fdacdd3
420 changed files with 2316 additions and 1840 deletions

View File

@@ -7,22 +7,24 @@
*
*/
namespace phpbb\db\migration\tool;
/**
* Migration config tool
*
* @package db
*/
class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_tool_interface
class config implements \phpbb\db\migration\tool\tool_interface
{
/** @var phpbb_config */
/** @var \phpbb\config\config */
protected $config;
/**
* Constructor
*
* @param phpbb_config $config
* @param \phpbb\config\config $config
*/
public function __construct(phpbb_config $config)
public function __construct(\phpbb\config\config $config)
{
$this->config = $config;
}
@@ -67,7 +69,7 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_tool_int
{
if (!isset($this->config[$config_name]))
{
throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name);
throw new \phpbb\db\migration\exception('CONFIG_NOT_EXIST', $config_name);
}
$this->config->set($config_name, $config_value);
@@ -78,7 +80,7 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_tool_int
* current config value
*
* @param string $compare If equal to the current config value, will be
* updated to the new config value, otherwise not
* updated to the new \config value, otherwise not
* @param string $config_name The name of the config setting you would
* like to update
* @param mixed $config_value The value of the config setting
@@ -88,7 +90,7 @@ class phpbb_db_migration_tool_config implements phpbb_db_migration_tool_tool_int
{
if (!isset($this->config[$config_name]))
{
throw new phpbb_db_migration_exception('CONFIG_NOT_EXIST', $config_name);
throw new \phpbb\db\migration\exception('CONFIG_NOT_EXIST', $config_name);
}
$this->config->set_atomic($config_name, $compare, $config_value);

View File

@@ -7,20 +7,22 @@
*
*/
namespace phpbb\db\migration\tool;
/**
* Migration module management tool
*
* @package db
*/
class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_interface
class module implements \phpbb\db\migration\tool\tool_interface
{
/** @var phpbb_cache_service */
/** @var \phpbb\cache\service */
protected $cache;
/** @var dbal */
protected $db;
/** @var phpbb_user */
/** @var \phpbb\user */
protected $user;
/** @var string */
@@ -35,14 +37,14 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_int
/**
* Constructor
*
* @param phpbb_db_driver $db
* @param \phpbb\db\driver\driver $db
* @param mixed $cache
* @param phpbb_user $user
* @param \phpbb\user $user
* @param string $phpbb_root_path
* @param string $php_ext
* @param string $modules_table
*/
public function __construct(phpbb_db_driver $db, phpbb_cache_service $cache, phpbb_user $user, $phpbb_root_path, $php_ext, $modules_table)
public function __construct(\phpbb\db\driver\driver $db, \phpbb\cache\service $cache, \phpbb\user $user, $phpbb_root_path, $php_ext, $modules_table)
{
$this->db = $db;
$this->cache = $cache;
@@ -129,11 +131,11 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_int
/**
* Module Add
*
* Add a new module
* Add a new \module
*
* @param string $class The module class(acp|mcp|ucp)
* @param int|string $parent The parent module_id|module_langname (0 for no parent)
* @param array $data an array of the data on the new module.
* @param array $data an array of the data on the new \module.
* This can be setup in two different ways.
* 1. The "manual" way. For inserting a category or one at a time.
* It will be merged with the base array shown a bit below,
@@ -221,14 +223,14 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_int
if (!$module_id)
{
throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent);
throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent);
}
$parent = $data['parent_id'] = $module_id;
}
else if (!$this->exists($class, false, $parent))
{
throw new phpbb_db_migration_exception('MODULE_NOT_EXIST', $parent);
throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST', $parent);
}
if ($this->exists($class, $parent, $data['module_langname']))
@@ -241,7 +243,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_int
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
$this->user->add_lang('acp/modules');
}
$acp_modules = new acp_modules();
$acp_modules = new \acp_modules();
$module_data = array(
'module_enabled' => (isset($data['module_enabled'])) ? $data['module_enabled'] : 1,
@@ -259,7 +261,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_int
if (is_string($result))
{
// Error
throw new phpbb_db_migration_exception('MODULE_ERROR', $result);
throw new \phpbb\db\migration\exception('MODULE_ERROR', $result);
}
else
{
@@ -347,7 +349,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_int
// Failed.
if (!isset($module['module_basename']))
{
throw new phpbb_db_migration_exception('MODULE_NOT_EXIST');
throw new \phpbb\db\migration\exception('MODULE_NOT_EXIST');
}
// Automatic method
@@ -433,7 +435,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_int
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
$this->user->add_lang('acp/modules');
}
$acp_modules = new acp_modules();
$acp_modules = new \acp_modules();
$acp_modules->module_class = $class;
foreach ($module_ids as $module_id)
@@ -476,7 +478,7 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_int
}
/**
* Wrapper for acp_modules::get_module_infos()
* Wrapper for \acp_modules::get_module_infos()
*
* @param string $class Module Class
* @param string $basename Module Basename
@@ -488,12 +490,12 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_tool_int
{
include($this->phpbb_root_path . 'includes/acp/acp_modules.' . $this->php_ext);
}
$acp_modules = new acp_modules();
$acp_modules = new \acp_modules();
$module = $acp_modules->get_module_infos($basename, $class, true);
if (empty($module))
{
throw new phpbb_db_migration_exception('MODULE_INFO_FILE_NOT_EXIST', $class, $basename);
throw new \phpbb\db\migration\exception('MODULE_INFO_FILE_NOT_EXIST', $class, $basename);
}
return array_pop($module);

View File

@@ -7,17 +7,19 @@
*
*/
namespace phpbb\db\migration\tool;
/**
* Migration permission management tool
*
* @package db
*/
class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool_interface
class permission implements \phpbb\db\migration\tool\tool_interface
{
/** @var phpbb_auth */
/** @var \phpbb\auth\auth */
protected $auth;
/** @var phpbb_cache_service */
/** @var \phpbb\cache\service */
protected $cache;
/** @var dbal */
@@ -32,13 +34,13 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool
/**
* Constructor
*
* @param phpbb_db_driver $db
* @param \phpbb\db\driver\driver $db
* @param mixed $cache
* @param phpbb_auth $auth
* @param \phpbb\auth\auth $auth
* @param string $phpbb_root_path
* @param string $php_ext
*/
public function __construct(phpbb_db_driver $db, phpbb_cache_service $cache, phpbb_auth $auth, $phpbb_root_path, $php_ext)
public function __construct(\phpbb\db\driver\driver $db, \phpbb\cache\service $cache, \phpbb\auth\auth $auth, $phpbb_root_path, $php_ext)
{
$this->db = $db;
$this->cache = $cache;
@@ -117,7 +119,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool
{
include($this->phpbb_root_path . 'includes/acp/auth.' . $this->php_ext);
}
$auth_admin = new auth_admin();
$auth_admin = new \auth_admin();
// We have to add a check to see if the !$global (if global, local, and if local, global) permission already exists. If it does, acl_add_option currently has a bug which would break the ACL system, so we are having a work-around here.
if ($this->exists($auth_option, !$global))
@@ -236,9 +238,9 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool
}
/**
* Add a new permission role
* Add a new \permission role
*
* @param string $role_name The new role name
* @param string $role_name The new \role name
* @param sting $role_type The type (u_, m_, a_)
* @return null
*/
@@ -277,7 +279,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool
* Update the name on a permission role
*
* @param string $old_role_name The old role name
* @param string $new_role_name The new role name
* @param string $new_role_name The new \role name
* @return null
*/
public function role_update($old_role_name, $new_role_name)
@@ -290,7 +292,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool
if (!$role_id)
{
throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $old_role_name);
throw new \phpbb\db\migration\exception('ROLE_NOT_EXIST', $old_role_name);
}
$sql = 'UPDATE ' . ACL_ROLES_TABLE . "
@@ -380,7 +382,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool
if (!$role_id)
{
throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $name);
throw new \phpbb\db\migration\exception('ROLE_NOT_EXIST', $name);
}
$sql = 'SELECT auth_option_id, auth_setting
@@ -403,7 +405,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool
if (!$group_id)
{
throw new phpbb_db_migration_exception('GROUP_NOT_EXIST', $name);
throw new \phpbb\db\migration\exception('GROUP_NOT_EXIST', $name);
}
// If the group has a role set for them we will add the requested permissions to that role.
@@ -523,7 +525,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool
if (!$role_id)
{
throw new phpbb_db_migration_exception('ROLE_NOT_EXIST', $name);
throw new \phpbb\db\migration\exception('ROLE_NOT_EXIST', $name);
}
$sql = 'DELETE FROM ' . ACL_ROLES_DATA_TABLE . '
@@ -540,7 +542,7 @@ class phpbb_db_migration_tool_permission implements phpbb_db_migration_tool_tool
if (!$group_id)
{
throw new phpbb_db_migration_exception('GROUP_NOT_EXIST', $name);
throw new \phpbb\db\migration\exception('GROUP_NOT_EXIST', $name);
}
// If the group has a role set for them we will remove the requested permissions from that role.

View File

@@ -7,12 +7,14 @@
*
*/
namespace phpbb\db\migration\tool;
/**
* Migration tool interface
*
* @package db
*/
interface phpbb_db_migration_tool_tool_interface
interface tool_interface
{
/**
* Retrieve a short name used for commands in migrations.