mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00: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:
parent
5e0dc9ef2e
commit
3a5247d01b
16 changed files with 34 additions and 39 deletions
|
@ -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 = [];
|
||||
/**
|
||||
|
|
|
@ -190,7 +190,7 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
|
|||
'autoescape' => false,
|
||||
]
|
||||
);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $this->language, $phpbb_dispatcher);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $this->language);
|
||||
$phpbb_container->set('template.twig.extensions.phpbb', $twig_extension);
|
||||
|
||||
$twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||
|
|
|
@ -119,7 +119,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
|
|||
$assets_bag = new \phpbb\template\assets_bag();
|
||||
$context = new \phpbb\template\context();
|
||||
$loader = new \phpbb\template\twig\loader('');
|
||||
$this->dispatcher = new \phpbb\event\dispatcher();
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$assets_bag,
|
||||
$this->config,
|
||||
|
@ -128,7 +127,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
|
|||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
$this->dispatcher,
|
||||
new \phpbb\event\dispatcher(),
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
|
@ -136,7 +135,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
|
|||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user, $this->dispatcher)));
|
||||
$this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
|
||||
$this->extension_manager = new phpbb_mock_extension_manager(
|
||||
|
|
|
@ -87,7 +87,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
|
|||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $lang, $dispatcher);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $lang);
|
||||
$phpbb_container->set('template.twig.extensions.phpbb', $twig_extension);
|
||||
|
||||
$twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container);
|
||||
|
|
|
@ -117,7 +117,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
|
|||
$lang = new \phpbb\language\language($lang_loader);
|
||||
$this->user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||
|
||||
$this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user, $phpbb_dispatcher)));
|
||||
$this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
}
|
||||
|
||||
|
|
|
@ -102,7 +102,6 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
|
|||
$loader = new \phpbb\template\twig\loader([]);
|
||||
$log = new \phpbb\log\dummy();
|
||||
$assets_bag = new \phpbb\template\assets_bag();
|
||||
$dispatcher = new \phpbb\event\dispatcher();
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$assets_bag,
|
||||
$config,
|
||||
|
@ -111,7 +110,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
|
|||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
$dispatcher,
|
||||
new \phpbb\event\dispatcher(),
|
||||
[
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
|
@ -127,7 +126,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
|
|||
$cache_path,
|
||||
$this->user,
|
||||
[
|
||||
new \phpbb\template\twig\extension($context, $twig, $this->lang, $dispatcher),
|
||||
new \phpbb\template\twig\extension($context, $twig, $this->lang),
|
||||
new \phpbb\template\twig\extension\avatar($avatar_helper),
|
||||
new \phpbb\template\twig\extension\config($config),
|
||||
new \phpbb\template\twig\extension\icon($this->user),
|
||||
|
|
|
@ -60,7 +60,6 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
|
|||
$loader = new \phpbb\template\twig\loader('');
|
||||
$log = new \phpbb\log\dummy();
|
||||
$assets_bag = new \phpbb\template\assets_bag();
|
||||
$dispatcher = new \phpbb\event\dispatcher();
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$assets_bag,
|
||||
$config,
|
||||
|
@ -69,7 +68,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
|
|||
$cache_path,
|
||||
$this->extension_manager,
|
||||
$loader,
|
||||
$dispatcher,
|
||||
new \phpbb\event\dispatcher(),
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
|
@ -77,7 +76,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
|
|||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user, $dispatcher)), $this->extension_manager);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)), $this->extension_manager);
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
|
||||
$this->template_path = $this->test_path . '/templates';
|
||||
|
|
|
@ -154,7 +154,6 @@ Zeta test event in all',
|
|||
$loader = new \phpbb\template\twig\loader('');
|
||||
$log = new \phpbb\log\dummy();
|
||||
$assets_bag = new \phpbb\template\assets_bag();
|
||||
$dispatcher = new \phpbb\event\dispatcher();
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$assets_bag,
|
||||
$config,
|
||||
|
@ -163,7 +162,7 @@ Zeta test event in all',
|
|||
$cache_path,
|
||||
$this->extension_manager,
|
||||
$loader,
|
||||
$dispatcher,
|
||||
new \phpbb\event\dispatcher(),
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
|
@ -171,7 +170,7 @@ Zeta test event in all',
|
|||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user, $dispatcher)), $this->extension_manager);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)), $this->extension_manager);
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
|
||||
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
|
||||
|
|
|
@ -46,7 +46,6 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
|
|||
$loader = new \phpbb\template\twig\loader('');
|
||||
$log = new \phpbb\log\dummy();
|
||||
$assets_bag = new \phpbb\template\assets_bag();
|
||||
$dispatcher = new \phpbb\event\dispatcher();
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$assets_bag,
|
||||
$config,
|
||||
|
@ -55,7 +54,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
|
|||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
$dispatcher,
|
||||
new \phpbb\event\dispatcher(),
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
|
@ -70,7 +69,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
|
|||
$twig,
|
||||
$cache_path,
|
||||
$this->user,
|
||||
array(new \phpbb\template\twig\extension($context, $twig, $this->user, $dispatcher)),
|
||||
array(new \phpbb\template\twig\extension($context, $twig, $this->user)),
|
||||
new phpbb_mock_extension_manager(
|
||||
__DIR__ . '/',
|
||||
array(
|
||||
|
|
|
@ -97,7 +97,6 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
|||
$loader = new \phpbb\template\twig\loader('');
|
||||
$log = new \phpbb\log\dummy();
|
||||
$assets_bag = new \phpbb\template\assets_bag();
|
||||
$dispatcher = new \phpbb\event\dispatcher();
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$assets_bag,
|
||||
$config,
|
||||
|
@ -106,7 +105,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
|||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
$dispatcher,
|
||||
new \phpbb\event\dispatcher(),
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
|
@ -114,8 +113,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
|||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
|
||||
$this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $lang, $dispatcher)));
|
||||
$this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $lang)));
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
$this->template->set_custom_style('tests', $this->template_path);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
|
|||
$loader = new \phpbb\template\twig\loader('');
|
||||
$log = new \phpbb\log\dummy();
|
||||
$assets_bag = new \phpbb\template\assets_bag();
|
||||
$dispatcher = new \phpbb\event\dispatcher();
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$assets_bag,
|
||||
$config,
|
||||
|
@ -56,7 +55,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
|
|||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
$dispatcher,
|
||||
new \phpbb\event\dispatcher(),
|
||||
array(
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
|
@ -64,7 +63,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
|
|||
'autoescape' => false,
|
||||
)
|
||||
);
|
||||
$this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user, $dispatcher)));
|
||||
$this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
|
||||
}
|
||||
|
|
|
@ -65,7 +65,6 @@ class twig_test extends \phpbb_test_case
|
|||
$loader = new \phpbb\template\twig\loader('');
|
||||
$log = new \phpbb\log\dummy();
|
||||
$assets_bag = new \phpbb\template\assets_bag();
|
||||
$dispatcher = new \phpbb\event\dispatcher();
|
||||
$twig = new \phpbb\template\twig\environment(
|
||||
$assets_bag,
|
||||
$config,
|
||||
|
@ -74,7 +73,7 @@ class twig_test extends \phpbb_test_case
|
|||
$cache_path,
|
||||
null,
|
||||
$loader,
|
||||
$dispatcher,
|
||||
new \phpbb\event\dispatcher(),
|
||||
[
|
||||
'cache' => false,
|
||||
'debug' => false,
|
||||
|
@ -82,7 +81,7 @@ class twig_test extends \phpbb_test_case
|
|||
'autoescape' => false,
|
||||
]
|
||||
);
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user, $dispatcher)));
|
||||
$this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
|
||||
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
|
||||
}
|
||||
|
||||
|
|
|
@ -407,7 +407,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
'autoescape' => false,
|
||||
]
|
||||
);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $lang, $phpbb_dispatcher);
|
||||
$twig_extension = new \phpbb\template\twig\extension($context, $twig, $lang);
|
||||
$container->set('template.twig.extensions.phpbb', $twig_extension);
|
||||
|
||||
$twig_extensions_collection = new \phpbb\di\service_collection($container);
|
||||
|
|
Loading…
Add table
Reference in a new issue