mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 20:38:52 +00:00
[feature/twig] Attempt to automatically set style dir for ext controllers
Extension authors can change it themselves if necessary PHPBB3-11598
This commit is contained in:
parent
81f27fd87e
commit
2fb48d60f1
2 changed files with 28 additions and 2 deletions
|
@ -79,7 +79,7 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
- @user
|
- @user
|
||||||
- @service_container
|
- @service_container
|
||||||
- @ext.finder
|
- @style
|
||||||
|
|
||||||
cron.task_collection:
|
cron.task_collection:
|
||||||
class: phpbb_di_service_collection
|
class: phpbb_di_service_collection
|
||||||
|
|
|
@ -37,16 +37,24 @@ class phpbb_controller_resolver implements ControllerResolverInterface
|
||||||
*/
|
*/
|
||||||
protected $container;
|
protected $container;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* phpbb_style object
|
||||||
|
* @var phpbb_style
|
||||||
|
*/
|
||||||
|
protected $style;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct method
|
* Construct method
|
||||||
*
|
*
|
||||||
* @param phpbb_user $user User Object
|
* @param phpbb_user $user User Object
|
||||||
* @param ContainerInterface $container ContainerInterface object
|
* @param ContainerInterface $container ContainerInterface object
|
||||||
|
* @param phpbb_style $style
|
||||||
*/
|
*/
|
||||||
public function __construct(phpbb_user $user, ContainerInterface $container)
|
public function __construct(phpbb_user $user, ContainerInterface $container, phpbb_style $style)
|
||||||
{
|
{
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
|
$this->style = $style;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,6 +88,24 @@ class phpbb_controller_resolver implements ControllerResolverInterface
|
||||||
|
|
||||||
$controller_object = $this->container->get($service);
|
$controller_object = $this->container->get($service);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If this is an extension controller, we'll try to automatically set
|
||||||
|
* the style paths for the extension (the ext author can change them
|
||||||
|
* if necessary).
|
||||||
|
*/
|
||||||
|
$controller_dir = explode('_', get_class($controller_object));
|
||||||
|
|
||||||
|
// 0 phpbb, 1 ext, 2 vendor, 3 extension name, ...
|
||||||
|
if ($controller_dir[1] === 'ext')
|
||||||
|
{
|
||||||
|
$controller_style_dir = 'ext/' . $controller_dir[2] . '/' . $controller_dir[3] . '/styles';
|
||||||
|
|
||||||
|
if (is_dir($controller_style_dir))
|
||||||
|
{
|
||||||
|
$this->style->set_style(array($controller_style_dir, 'styles'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return array($controller_object, $method);
|
return array($controller_object, $method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue