mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +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:
@@ -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);
|
||||
|
@@ -91,7 +91,7 @@ class helper
|
||||
|
||||
page_footer(true, false, false);
|
||||
|
||||
return new \Response($this->template->assign_display('body'), $status_code);
|
||||
return new Response($this->template->assign_display('body'), $status_code);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -95,12 +95,12 @@ class resolver implements ControllerResolverInterface
|
||||
* the style paths for the extension (the ext author can change them
|
||||
* if necessary).
|
||||
*/
|
||||
$controller_dir = explode('_', get_class($controller_object));
|
||||
$controller_dir = explode('\\', get_class($controller_object));
|
||||
|
||||
// 0 phpbb, 1 ext, 2 vendor, 3 extension name, ...
|
||||
if (!is_null($this->template) && isset($controller_dir[3]) && $controller_dir[1] === 'ext')
|
||||
// 0 vendor, 1 extension name, ...
|
||||
if (!is_null($this->template) && isset($controller_dir[1]))
|
||||
{
|
||||
$controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles';
|
||||
$controller_style_dir = 'ext/' . $controller_dir[0] . '/' . $controller_dir[1] . '/styles';
|
||||
|
||||
if (is_dir($controller_style_dir))
|
||||
{
|
||||
|
@@ -55,7 +55,7 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
||||
* @param GetResponseForExceptionEvent $event
|
||||
* @return null
|
||||
*/
|
||||
public function on_kernel_exception(\GetResponseForExceptionEvent $event)
|
||||
public function on_kernel_exception(GetResponseForExceptionEvent $event)
|
||||
{
|
||||
page_header($this->user->lang('INFORMATION'));
|
||||
|
||||
@@ -74,7 +74,7 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
||||
|
||||
|
||||
$status_code = $exception instanceof HttpException ? $exception->getStatusCode() : 500;
|
||||
$response = new \Response($this->template->assign_display('body'), $status_code);
|
||||
$response = new Response($this->template->assign_display('body'), $status_code);
|
||||
$event->setResponse($response);
|
||||
}
|
||||
|
||||
|
@@ -65,14 +65,14 @@ class kernel_request_subscriber implements EventSubscriberInterface
|
||||
* @param GetResponseEvent $event
|
||||
* @return null
|
||||
*/
|
||||
public function on_kernel_request(\GetResponseEvent $event)
|
||||
public function on_kernel_request(GetResponseEvent $event)
|
||||
{
|
||||
$request = $event->getRequest();
|
||||
$context = new \RequestContext();
|
||||
$context = new RequestContext();
|
||||
$context->fromRequest($request);
|
||||
|
||||
$matcher = phpbb_get_url_matcher($this->finder, $context, $this->root_path, $this->php_ext);
|
||||
$router_listener = new \RouterListener($matcher, $context);
|
||||
$router_listener = new RouterListener($matcher, $context);
|
||||
$router_listener->onKernelRequest($event);
|
||||
}
|
||||
|
||||
|
@@ -31,7 +31,7 @@ class kernel_terminate_subscriber implements EventSubscriberInterface
|
||||
* @param PostResponseEvent $event
|
||||
* @return null
|
||||
*/
|
||||
public function on_kernel_terminate(\PostResponseEvent $event)
|
||||
public function on_kernel_terminate(PostResponseEvent $event)
|
||||
{
|
||||
exit_handler();
|
||||
}
|
||||
|
Reference in New Issue
Block a user