[ticket/12529] Use root_path in controller\resolver to check the template dir

PHPBB3-12529
This commit is contained in:
Tristan Darricau 2014-05-11 14:10:19 +02:00
parent d4fc060bcd
commit 197c801746
3 changed files with 11 additions and 3 deletions

View file

@ -103,6 +103,7 @@ services:
class: phpbb\controller\resolver class: phpbb\controller\resolver
arguments: arguments:
- @user - @user
- %core.root_path%
- @service_container - @service_container
- @template - @template

View file

@ -37,6 +37,12 @@ class resolver implements ControllerResolverInterface
*/ */
protected $template; protected $template;
/**
* phpBB root path
* @var string
*/
protected $phpbb_root_path;
/** /**
* Construct method * Construct method
* *
@ -44,11 +50,12 @@ class resolver implements ControllerResolverInterface
* @param ContainerInterface $container ContainerInterface object * @param ContainerInterface $container ContainerInterface object
* @param \phpbb\template\template $template * @param \phpbb\template\template $template
*/ */
public function __construct(\phpbb\user $user, ContainerInterface $container, \phpbb\template\template $template = null) public function __construct(\phpbb\user $user, $phpbb_root_path, ContainerInterface $container, \phpbb\template\template $template = null)
{ {
$this->user = $user; $this->user = $user;
$this->container = $container; $this->container = $container;
$this->template = $template; $this->template = $template;
$this->phpbb_root_path = $phpbb_root_path;
} }
/** /**
@ -94,7 +101,7 @@ class resolver implements ControllerResolverInterface
{ {
$controller_style_dir = 'ext/' . $controller_dir[0] . '/' . $controller_dir[1] . '/styles'; $controller_style_dir = 'ext/' . $controller_dir[0] . '/' . $controller_dir[1] . '/styles';
if (is_dir($controller_style_dir)) if (is_dir($this->phpbb_root_path . $controller_style_dir))
{ {
$this->template->set_style(array($controller_style_dir, 'styles')); $this->template->set_style(array($controller_style_dir, 'styles'));
} }

View file

@ -68,7 +68,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
include(__DIR__.'/phpbb/controller/foo.php'); include(__DIR__.'/phpbb/controller/foo.php');
} }
$resolver = new \phpbb\controller\resolver(new \phpbb\user, $container); $resolver = new \phpbb\controller\resolver(new \phpbb\user, dirname(__FILE__) . '/', $container);
$symfony_request = new Request(); $symfony_request = new Request();
$symfony_request->attributes->set('_controller', 'foo.controller:handle'); $symfony_request->attributes->set('_controller', 'foo.controller:handle');