mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-08 01:36:57 +02:00
[ticket/15214] Get event dispatcher from environment rather than as dependency
Also this will allow to significantly reduce unrelated tests changes. PHPBB3-15214
This commit is contained in:
@@ -40,7 +40,6 @@ services:
|
||||
- '@template_context'
|
||||
- '@template.twig.environment'
|
||||
- '@language'
|
||||
- '@dispatcher'
|
||||
tags:
|
||||
- { name: twig.extension }
|
||||
|
||||
|
@@ -161,6 +161,16 @@ class environment extends \Twig\Environment
|
||||
return $this->assets_bag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the event dispatcher instance
|
||||
*
|
||||
* @return dispatcher_interface
|
||||
*/
|
||||
public function get_phpbb_dispatcher()
|
||||
{
|
||||
return $this->phpbb_dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the namespace look up order
|
||||
*
|
||||
|
@@ -28,23 +28,18 @@ class extension extends \Twig\Extension\AbstractExtension
|
||||
/** @var \phpbb\language\language */
|
||||
protected $language;
|
||||
|
||||
/** @var \phpbb\event\dispatcher_interface */
|
||||
protected $phpbb_dispatcher;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \phpbb\template\context $context
|
||||
* @param \phpbb\template\twig\environment $environment
|
||||
* @param \phpbb\language\language $language
|
||||
* @param \phpbb\event\dispatcher_interface $phpbb_dispatcher
|
||||
*/
|
||||
public function __construct(\phpbb\template\context $context, \phpbb\template\twig\environment $environment, $language, \phpbb\event\dispatcher_interface $phpbb_dispatcher)
|
||||
public function __construct(\phpbb\template\context $context, \phpbb\template\twig\environment $environment, $language)
|
||||
{
|
||||
$this->context = $context;
|
||||
$this->environment = $environment;
|
||||
$this->language = $language;
|
||||
$this->phpbb_dispatcher = $phpbb_dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +64,7 @@ class extension extends \Twig\Extension\AbstractExtension
|
||||
new \phpbb\template\twig\tokenparser\includeparser,
|
||||
new \phpbb\template\twig\tokenparser\includejs,
|
||||
new \phpbb\template\twig\tokenparser\includecss,
|
||||
new \phpbb\template\twig\tokenparser\event($this->environment, $this->phpbb_dispatcher),
|
||||
new \phpbb\template\twig\tokenparser\event($this->environment),
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -29,10 +29,10 @@ class event extends \Twig\TokenParser\AbstractTokenParser
|
||||
*
|
||||
* @param \phpbb\template\twig\environment $environment
|
||||
*/
|
||||
public function __construct(\phpbb\template\twig\environment $environment, \phpbb\event\dispatcher_interface $phpbb_dispatcher = null)
|
||||
public function __construct(\phpbb\template\twig\environment $environment)
|
||||
{
|
||||
$this->environment = $environment;
|
||||
$this->phpbb_dispatcher = $phpbb_dispatcher;
|
||||
$this->phpbb_dispatcher = $this->environment->get_phpbb_dispatcher();
|
||||
|
||||
$template_event_priority_array = [];
|
||||
/**
|
||||
|
Reference in New Issue
Block a user