mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/11700] Move all recent code to namespaces
PHPBB3-11700
This commit is contained in:
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\extension;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -22,15 +24,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
*
|
||||
* @package extension
|
||||
*/
|
||||
class phpbb_extension_base implements phpbb_extension_extension_interface
|
||||
class base implements \phpbb\extension\extension_interface
|
||||
{
|
||||
/** @var ContainerInterface */
|
||||
protected $container;
|
||||
|
||||
/** @var phpbb_extension_finder */
|
||||
/** @var \phpbb\extension\finder */
|
||||
protected $finder;
|
||||
|
||||
/** @var phpbb_db_migrator */
|
||||
/** @var \phpbb\db\migrator */
|
||||
protected $migrator;
|
||||
|
||||
/** @var string */
|
||||
@@ -43,11 +45,11 @@ class phpbb_extension_base implements phpbb_extension_extension_interface
|
||||
* Constructor
|
||||
*
|
||||
* @param ContainerInterface $container Container object
|
||||
* @param phpbb_extension_finder $extension_finder
|
||||
* @param \phpbb\extension\finder $extension_finder
|
||||
* @param string $extension_name Name of this extension (from ext.manager)
|
||||
* @param string $extension_path Relative path to this extension
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, phpbb_extension_finder $extension_finder, phpbb_db_migrator $migrator, $extension_name, $extension_path)
|
||||
public function __construct(ContainerInterface $container, \phpbb\extension\finder $extension_finder, \phpbb\db\migrator $migrator, $extension_name, $extension_path)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->extension_finder = $extension_finder;
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\extension;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -18,7 +20,7 @@ if (!defined('IN_PHPBB'))
|
||||
/**
|
||||
* Exception class for metadata
|
||||
*/
|
||||
class phpbb_extension_exception extends UnexpectedValueException
|
||||
class exception extends \UnexpectedValueException
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\extension;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -21,7 +23,7 @@ if (!defined('IN_PHPBB'))
|
||||
*
|
||||
* @package extension
|
||||
*/
|
||||
interface phpbb_extension_extension_interface
|
||||
interface extension_interface
|
||||
{
|
||||
/**
|
||||
* enable_step is executed on enabling an extension until it returns false.
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\extension;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -20,7 +22,7 @@ if (!defined('IN_PHPBB'))
|
||||
*
|
||||
* @package extension
|
||||
*/
|
||||
class phpbb_extension_finder
|
||||
class finder
|
||||
{
|
||||
protected $extension_manager;
|
||||
protected $filesystem;
|
||||
@@ -50,19 +52,19 @@ class phpbb_extension_finder
|
||||
protected $cached_queries;
|
||||
|
||||
/**
|
||||
* Creates a new finder instance with its dependencies
|
||||
* Creates a new \finder instance with its dependencies
|
||||
*
|
||||
* @param phpbb_extension_manager $extension_manager An extension manager
|
||||
* @param \phpbb\extension\manager $extension_manager An extension manager
|
||||
* instance that provides the finder with a list of active
|
||||
* extensions and their locations
|
||||
* @param phpbb_filesystem $filesystem Filesystem instance
|
||||
* @param \phpbb\filesystem $filesystem Filesystem instance
|
||||
* @param string $phpbb_root_path Path to the phpbb root directory
|
||||
* @param phpbb_cache_driver_driver_interface $cache A cache instance or null
|
||||
* @param \phpbb\cache\driver\driver_interface $cache A cache instance or null
|
||||
* @param string $php_ext php file extension
|
||||
* @param string $cache_name The name of the cache variable, defaults to
|
||||
* _ext_finder
|
||||
*/
|
||||
public function __construct(phpbb_extension_manager $extension_manager, phpbb_filesystem $filesystem, $phpbb_root_path = '', phpbb_cache_driver_driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder')
|
||||
public function __construct(\phpbb\extension\manager $extension_manager, \phpbb\filesystem $filesystem, $phpbb_root_path = '', \phpbb\cache\driver\driver_interface $cache = null, $php_ext = 'php', $cache_name = '_ext_finder')
|
||||
{
|
||||
$this->extension_manager = $extension_manager;
|
||||
$this->filesystem = $filesystem;
|
||||
@@ -88,7 +90,7 @@ class phpbb_extension_finder
|
||||
* Sets a core path to be searched in addition to extensions
|
||||
*
|
||||
* @param string $core_path The path relative to phpbb_root_path
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function core_path($core_path)
|
||||
{
|
||||
@@ -104,7 +106,7 @@ class phpbb_extension_finder
|
||||
* file extension is automatically added to suffixes.
|
||||
*
|
||||
* @param string $suffix A filename suffix
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function suffix($suffix)
|
||||
{
|
||||
@@ -121,7 +123,7 @@ class phpbb_extension_finder
|
||||
* file extension is automatically added to suffixes.
|
||||
*
|
||||
* @param string $extension_suffix A filename suffix
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function extension_suffix($extension_suffix)
|
||||
{
|
||||
@@ -137,7 +139,7 @@ class phpbb_extension_finder
|
||||
* file extension is automatically added to suffixes.
|
||||
*
|
||||
* @param string $core_suffix A filename suffix
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function core_suffix($core_suffix)
|
||||
{
|
||||
@@ -149,7 +151,7 @@ class phpbb_extension_finder
|
||||
* Sets the prefix all files found in extensions and core must match
|
||||
*
|
||||
* @param string $prefix A filename prefix
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function prefix($prefix)
|
||||
{
|
||||
@@ -162,7 +164,7 @@ class phpbb_extension_finder
|
||||
* Sets a prefix all files found in extensions must match
|
||||
*
|
||||
* @param string $extension_prefix A filename prefix
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function extension_prefix($extension_prefix)
|
||||
{
|
||||
@@ -174,7 +176,7 @@ class phpbb_extension_finder
|
||||
* Sets a prefix all files found in the core path must match
|
||||
*
|
||||
* @param string $core_prefix A filename prefix
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function core_prefix($core_prefix)
|
||||
{
|
||||
@@ -189,7 +191,7 @@ class phpbb_extension_finder
|
||||
* the current directory.
|
||||
*
|
||||
* @param string $directory
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function directory($directory)
|
||||
{
|
||||
@@ -202,7 +204,7 @@ class phpbb_extension_finder
|
||||
* Sets a directory all files found in extensions must be contained in
|
||||
*
|
||||
* @param string $extension_directory
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function extension_directory($extension_directory)
|
||||
{
|
||||
@@ -214,7 +216,7 @@ class phpbb_extension_finder
|
||||
* Sets a directory all files found in the core path must be contained in
|
||||
*
|
||||
* @param string $core_directory
|
||||
* @return phpbb_extension_finder This object for chaining calls
|
||||
* @return \phpbb\extension\finder This object for chaining calls
|
||||
*/
|
||||
public function core_directory($core_directory)
|
||||
{
|
||||
@@ -473,7 +475,7 @@ class phpbb_extension_finder
|
||||
}
|
||||
$directory_pattern = '#' . $directory_pattern . '#';
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
|
||||
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path), \RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($iterator as $file_info)
|
||||
{
|
||||
$filename = $file_info->getFilename();
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\extension;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -22,7 +24,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
*
|
||||
* @package extension
|
||||
*/
|
||||
class phpbb_extension_manager
|
||||
class manager
|
||||
{
|
||||
/** @var ContainerInterface */
|
||||
protected $container;
|
||||
@@ -40,16 +42,16 @@ class phpbb_extension_manager
|
||||
* Creates a manager and loads information from database
|
||||
*
|
||||
* @param ContainerInterface $container A container
|
||||
* @param phpbb_db_driver $db A database connection
|
||||
* @param phpbb_config $config phpbb_config
|
||||
* @param phpbb_filesystem $filesystem
|
||||
* @param \phpbb\db\driver\driver $db A database connection
|
||||
* @param \phpbb\config\config $config \phpbb\config\config
|
||||
* @param \phpbb\filesystem $filesystem
|
||||
* @param string $extension_table The name of the table holding extensions
|
||||
* @param string $phpbb_root_path Path to the phpbb includes directory.
|
||||
* @param string $php_ext php file extension
|
||||
* @param phpbb_cache_driver_driver_interface $cache A cache instance or null
|
||||
* @param \phpbb\cache\driver\driver_interface $cache A cache instance or null
|
||||
* @param string $cache_name The name of the cache variable, defaults to _ext
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, phpbb_db_driver $db, phpbb_config $config, phpbb_filesystem $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', phpbb_cache_driver_driver_interface $cache = null, $cache_name = '_ext')
|
||||
public function __construct(ContainerInterface $container, \phpbb\db\driver\driver $db, \phpbb\config\config $config, \phpbb\filesystem $filesystem, $extension_table, $phpbb_root_path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null, $cache_name = '_ext')
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
@@ -126,8 +128,8 @@ class phpbb_extension_manager
|
||||
* Instantiates the extension meta class for the extension with the given name
|
||||
*
|
||||
* @param string $name The extension name
|
||||
* @return phpbb_extension_extension_interface Instance of the extension meta class or
|
||||
* phpbb_extension_base if the class does not exist
|
||||
* @return \phpbb\extension\extension_interface Instance of the extension meta class or
|
||||
* \phpbb\extension\base if the class does not exist
|
||||
*/
|
||||
public function get_extension($name)
|
||||
{
|
||||
@@ -141,7 +143,7 @@ class phpbb_extension_manager
|
||||
}
|
||||
else
|
||||
{
|
||||
return new phpbb_extension_base($this->container, $this->get_finder(), $migrator, $name, $this->get_extension_path($name, true));
|
||||
return new \phpbb\extension\base($this->container, $this->get_finder(), $migrator, $name, $this->get_extension_path($name, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,11 +152,11 @@ class phpbb_extension_manager
|
||||
*
|
||||
* @param string $name The extension name
|
||||
* @param string $template The template manager
|
||||
* @return phpbb_extension_metadata_manager Instance of the metadata manager
|
||||
* @return \phpbb\extension\metadata_manager Instance of the metadata manager
|
||||
*/
|
||||
public function create_extension_metadata_manager($name, phpbb_template $template)
|
||||
public function create_extension_metadata_manager($name, \phpbb\template\template $template)
|
||||
{
|
||||
return new phpbb_extension_metadata_manager($name, $this->config, $this, $template, $this->phpbb_root_path);
|
||||
return new \phpbb\extension\metadata_manager($name, $this->config, $this, $template, $this->phpbb_root_path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,9 +405,9 @@ class phpbb_extension_manager
|
||||
return $available;
|
||||
}
|
||||
|
||||
$iterator = new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($this->phpbb_root_path . 'ext/', FilesystemIterator::NEW_CURRENT_AND_KEY | FilesystemIterator::FOLLOW_SYMLINKS),
|
||||
RecursiveIteratorIterator::SELF_FIRST);
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \RecursiveDirectoryIterator($this->phpbb_root_path . 'ext/', \FilesystemIterator::NEW_CURRENT_AND_KEY | \FilesystemIterator::FOLLOW_SYMLINKS),
|
||||
\RecursiveIteratorIterator::SELF_FIRST);
|
||||
foreach ($iterator as $file_info)
|
||||
{
|
||||
if ($file_info->isFile() && $file_info->getFilename() == 'ext.' . $this->php_ext)
|
||||
@@ -502,12 +504,12 @@ class phpbb_extension_manager
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a phpbb_extension_finder.
|
||||
* Instantiates a \phpbb\extension\finder.
|
||||
*
|
||||
* @return phpbb_extension_finder An extension finder instance
|
||||
* @return \phpbb\extension\finder An extension finder instance
|
||||
*/
|
||||
public function get_finder()
|
||||
{
|
||||
return new phpbb_extension_finder($this, $this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder');
|
||||
return new \phpbb\extension\finder($this, $this->filesystem, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder');
|
||||
}
|
||||
}
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\extension;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -20,23 +22,23 @@ if (!defined('IN_PHPBB'))
|
||||
*
|
||||
* @package extension
|
||||
*/
|
||||
class phpbb_extension_metadata_manager
|
||||
class metadata_manager
|
||||
{
|
||||
/**
|
||||
* phpBB Config instance
|
||||
* @var phpbb_config
|
||||
* @var \phpbb\config\config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* phpBB Extension Manager
|
||||
* @var phpbb_extension_manager
|
||||
* @var \phpbb\extension\manager
|
||||
*/
|
||||
protected $extension_manager;
|
||||
|
||||
/**
|
||||
* phpBB Template instance
|
||||
* @var phpbb_template
|
||||
* @var \phpbb\template\template
|
||||
*/
|
||||
protected $template;
|
||||
|
||||
@@ -68,12 +70,12 @@ class phpbb_extension_metadata_manager
|
||||
* Creates the metadata manager
|
||||
*
|
||||
* @param string $ext_name Name (including vendor) of the extension
|
||||
* @param phpbb_config $config phpBB Config instance
|
||||
* @param phpbb_extension_manager $extension_manager An instance of the phpBBb extension manager
|
||||
* @param phpbb_template $template phpBB Template instance
|
||||
* @param \phpbb\config\config $config phpBB Config instance
|
||||
* @param \phpbb\extension\manager $extension_manager An instance of the phpBBb extension manager
|
||||
* @param \phpbb\template\template $template phpBB Template instance
|
||||
* @param string $phpbb_root_path Path to the phpbb includes directory.
|
||||
*/
|
||||
public function __construct($ext_name, phpbb_config $config, phpbb_extension_manager $extension_manager, phpbb_template $template, $phpbb_root_path)
|
||||
public function __construct($ext_name, \phpbb\config\config $config, \phpbb\extension\manager $extension_manager, \phpbb\template\template $template, $phpbb_root_path)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->extension_manager = $extension_manager;
|
||||
@@ -145,7 +147,7 @@ class phpbb_extension_metadata_manager
|
||||
|
||||
if (!file_exists($this->metadata_file))
|
||||
{
|
||||
throw new phpbb_extension_exception('The required file does not exist: ' . $this->metadata_file);
|
||||
throw new \phpbb\extension\exception('The required file does not exist: ' . $this->metadata_file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,18 +160,18 @@ class phpbb_extension_metadata_manager
|
||||
{
|
||||
if (!file_exists($this->metadata_file))
|
||||
{
|
||||
throw new phpbb_extension_exception('The required file does not exist: ' . $this->metadata_file);
|
||||
throw new \phpbb\extension\exception('The required file does not exist: ' . $this->metadata_file);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!($file_contents = file_get_contents($this->metadata_file)))
|
||||
{
|
||||
throw new phpbb_extension_exception('file_get_contents failed on ' . $this->metadata_file);
|
||||
throw new \phpbb\extension\exception('file_get_contents failed on ' . $this->metadata_file);
|
||||
}
|
||||
|
||||
if (($metadata = json_decode($file_contents, true)) === NULL)
|
||||
{
|
||||
throw new phpbb_extension_exception('json_decode failed on ' . $this->metadata_file);
|
||||
throw new \phpbb\extension\exception('json_decode failed on ' . $this->metadata_file);
|
||||
}
|
||||
|
||||
$this->metadata = $metadata;
|
||||
@@ -228,12 +230,12 @@ class phpbb_extension_metadata_manager
|
||||
{
|
||||
if (!isset($this->metadata[$name]))
|
||||
{
|
||||
throw new phpbb_extension_exception("Required meta field '$name' has not been set.");
|
||||
throw new \phpbb\extension\exception("Required meta field '$name' has not been set.");
|
||||
}
|
||||
|
||||
if (!preg_match($fields[$name], $this->metadata[$name]))
|
||||
{
|
||||
throw new phpbb_extension_exception("Meta field '$name' is invalid.");
|
||||
throw new \phpbb\extension\exception("Meta field '$name' is invalid.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -251,14 +253,14 @@ class phpbb_extension_metadata_manager
|
||||
{
|
||||
if (empty($this->metadata['authors']))
|
||||
{
|
||||
throw new phpbb_extension_exception("Required meta field 'authors' has not been set.");
|
||||
throw new \phpbb\extension\exception("Required meta field 'authors' has not been set.");
|
||||
}
|
||||
|
||||
foreach ($this->metadata['authors'] as $author)
|
||||
{
|
||||
if (!isset($author['name']))
|
||||
{
|
||||
throw new phpbb_extension_exception("Required meta field 'author name' has not been set.");
|
||||
throw new \phpbb\extension\exception("Required meta field 'author name' has not been set.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\extension;
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
@@ -28,7 +30,7 @@ if (!defined('IN_PHPBB'))
|
||||
*
|
||||
* @package extension
|
||||
*/
|
||||
abstract class phpbb_extension_provider implements IteratorAggregate
|
||||
abstract class provider implements \IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* Array holding all found items
|
||||
@@ -38,16 +40,16 @@ abstract class phpbb_extension_provider implements IteratorAggregate
|
||||
|
||||
/**
|
||||
* An extension manager to search for items in extensions
|
||||
* @var phpbb_extension_manager
|
||||
* @var \phpbb\extension\manager
|
||||
*/
|
||||
protected $extension_manager;
|
||||
|
||||
/**
|
||||
* Constructor. Loads all available items.
|
||||
*
|
||||
* @param phpbb_extension_manager $extension_manager phpBB extension manager
|
||||
* @param \phpbb\extension\manager $extension_manager phpBB extension manager
|
||||
*/
|
||||
public function __construct(phpbb_extension_manager $extension_manager)
|
||||
public function __construct(\phpbb\extension\manager $extension_manager)
|
||||
{
|
||||
$this->extension_manager = $extension_manager;
|
||||
}
|
||||
@@ -71,6 +73,6 @@ abstract class phpbb_extension_provider implements IteratorAggregate
|
||||
$this->items = $this->find();
|
||||
}
|
||||
|
||||
return new ArrayIterator($this->items);
|
||||
return new \ArrayIterator($this->items);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user