1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-12 19:54:12 +02:00

[ticket/11700] Fix extension loading with namespaces

class loader now expects all classes to be prefixed with a backslash
when resolving paths

PHPBB3-11700
This commit is contained in:
Nils Adermann
2013-09-19 18:29:08 +02:00
parent f205c4fad4
commit fe36375a36
23 changed files with 72 additions and 46 deletions

View File

@@ -55,7 +55,12 @@ class class_loader
* @param \phpbb\cache\driver\driver_interface $cache An implementation of the phpBB cache interface.
*/
public function __construct($namespace, $path, $php_ext = 'php', \phpbb\cache\driver\driver_interface $cache = null)
{
{
if ($namespace[0] !== '\\')
{
$namespace = '\\' . $namespace;
}
$this->namespace = $namespace;
$this->path = $path;
$this->php_ext = $php_ext;
@@ -105,7 +110,8 @@ class class_loader
* Resolves a phpBB class name to a relative path which can be included.
*
* @param string $class The class name to resolve, must be in the
* namespace the loader was constructed with
* namespace the loader was constructed with.
* Has to begin with \
* @return string|bool A relative path to the file containing the
* class or false if looking it up failed.
*/
@@ -144,6 +150,7 @@ class class_loader
*/
public function load_class($class)
{
$class = '\\' . $class;
if (substr($class, 0, strlen($this->namespace)) === $this->namespace)
{
$path = $this->resolve_path($class);