[ticket/17176] Use Symfony name for event dispatcher

The previously used override of the names is no longer supported.

PHPBB3-17176
This commit is contained in:
Marc Alexander 2023-08-19 13:38:02 +02:00
parent 549c818a5c
commit 66b54d4469
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
32 changed files with 110 additions and 59 deletions

View file

@ -90,6 +90,6 @@ $user->data['user_id'] = ANONYMOUS;
$user->ip = '127.0.0.1';
$application = new \phpbb\console\application('phpBB Console', PHPBB_VERSION, $language, $config);
$application->setDispatcher($phpbb_container->get('dispatcher'));
$application->setDispatcher($phpbb_container->get('event_dispatcher'));
$application->register_container_commands($phpbb_container->get('console.command_collection'));
$application->run($input);

View file

@ -46,7 +46,7 @@ services:
- '@cache.driver'
- '@config'
- '@dbal.conn'
- '@dispatcher'
- '@event_dispatcher'
- '%core.root_path%'
- '%core.php_ext%'
@ -97,7 +97,7 @@ services:
- '@config'
- '@cron.manager'
- '@dbal.conn'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@request'
- '@routing.helper'
@ -132,7 +132,7 @@ services:
- '@cache'
- '@config'
- '@language'
- '@dispatcher'
- '@event_dispatcher'
- '@path_helper'
- '@user'
@ -142,7 +142,7 @@ services:
- '@dbal.conn'
- '@user'
- '@auth'
- '@dispatcher'
- '@event_dispatcher'
- '%core.root_path%'
- '%core.adm_relative_path%'
- '%core.php_ext%'

View file

@ -5,7 +5,7 @@ services:
arguments:
- '@config'
- '@dbal.conn'
- '@dispatcher'
- '@event_dispatcher'
- '@attachment.resync'
- '@storage.attachment'
@ -32,7 +32,7 @@ services:
- '@config'
- '@files.upload'
- '@language'
- '@dispatcher'
- '@event_dispatcher'
- '@plupload'
- '@storage.attachment'
- '@filesystem.temp'

View file

@ -52,7 +52,7 @@ services:
- '@config'
- '@dbal.conn'
- '@auth.provider.db'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@request'
- '@auth.provider.oauth.service_collection'

View file

@ -3,14 +3,14 @@ services:
class: phpbb\avatar\manager
arguments:
- '@config'
- '@dispatcher'
- '@event_dispatcher'
- '@avatar.driver_collection'
avatar.helper:
class: phpbb\avatar\helper
arguments:
- '@config'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@avatar.manager'
- '@path_helper'
@ -61,7 +61,7 @@ services:
- '%core.php_ext%'
- '@storage.avatar'
- '@path_helper'
- '@dispatcher'
- '@event_dispatcher'
- '@files.factory'
- '@php_ini'
calls:

View file

@ -4,7 +4,7 @@ services:
arguments:
- '@auth'
- '@config'
- '@dispatcher'
- '@event_dispatcher'
- '@dbal.conn'
- '@user'
- '%core.root_path%'
@ -33,7 +33,7 @@ services:
- '@config_text'
- '@dbal.conn'
- '@user'
- '@dispatcher'
- '@event_dispatcher'
- '%core.root_path%'
- '%core.php_ext%'
@ -63,7 +63,7 @@ services:
- '@template'
- '@user'
- '@controller.helper'
- '@dispatcher'
- '@event_dispatcher'
viewonline_helper:
class: phpbb\viewonline_helper

View file

@ -1,5 +1,5 @@
services:
dispatcher:
event_dispatcher:
class: phpbb\event\dispatcher
arguments:
- '@service_container'

View file

@ -11,7 +11,7 @@ services:
- '@feed.helper'
- '@user'
- '@auth'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '%core.php_ext%'
@ -36,7 +36,7 @@ services:
- '@user'
- '@auth'
- '@content.visibility'
- '@dispatcher'
- '@event_dispatcher'
- '%core.php_ext%'
feed.forums:
@ -50,7 +50,7 @@ services:
- '@user'
- '@auth'
- '@content.visibility'
- '@dispatcher'
- '@event_dispatcher'
- '%core.php_ext%'
feed.news:
@ -64,7 +64,7 @@ services:
- '@user'
- '@auth'
- '@content.visibility'
- '@dispatcher'
- '@event_dispatcher'
- '%core.php_ext%'
feed.overall:
@ -78,7 +78,7 @@ services:
- '@user'
- '@auth'
- '@content.visibility'
- '@dispatcher'
- '@event_dispatcher'
- '%core.php_ext%'
feed.quote_helper:
@ -96,7 +96,7 @@ services:
- '@user'
- '@auth'
- '@content.visibility'
- '@dispatcher'
- '@event_dispatcher'
- '%core.php_ext%'
feed.topics:
@ -110,7 +110,7 @@ services:
- '@user'
- '@auth'
- '@content.visibility'
- '@dispatcher'
- '@event_dispatcher'
- '%core.php_ext%'
feed.topics_active:
@ -124,5 +124,5 @@ services:
- '@user'
- '@auth'
- '@content.visibility'
- '@dispatcher'
- '@event_dispatcher'
- '%core.php_ext%'

View file

@ -2,7 +2,7 @@ services:
phpbb.help.manager:
class: phpbb\help\manager
arguments:
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@template'

View file

@ -2,7 +2,7 @@ services:
http_kernel:
class: Symfony\Component\HttpKernel\HttpKernel
arguments:
- '@dispatcher'
- '@event_dispatcher'
- '@controller.resolver'
- '@request_stack'

View file

@ -6,7 +6,7 @@ services:
- '@notification.method_collection'
- '@service_container'
- '@user_loader'
- '@dispatcher'
- '@event_dispatcher'
- '@dbal.conn'
- '@cache'
- '@language'

View file

@ -6,7 +6,7 @@ services:
- '@config_text'
- '@dbal.conn'
- '@dbal.tools'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@log'
- '@template'

View file

@ -35,7 +35,7 @@ services:
shared: false
arguments:
- '@dbal.conn.driver'
- '@dispatcher'
- '@event_dispatcher'
- '@config'
- '@auth'
- '@user'
@ -46,7 +46,7 @@ services:
shared: false
arguments:
- '@dbal.conn.driver'
- '@dispatcher'
- '@event_dispatcher'
- '@config'
- '@auth'
- '@user'

View file

@ -12,7 +12,7 @@ services:
arguments:
- '@config'
- '@dbal.conn'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@user'
- '%tables.search_results%'
@ -26,7 +26,7 @@ services:
arguments:
- '@config'
- '@dbal.conn'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@user'
- '%tables.search_results%'
@ -42,7 +42,7 @@ services:
arguments:
- '@config'
- '@dbal.conn'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@user'
- '%tables.search_results%'
@ -58,7 +58,7 @@ services:
- '@config'
- '@dbal.conn'
- '@dbal.tools'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@log'
- '@user'

View file

@ -101,7 +101,7 @@ services:
- '@config'
- '@content.visibility'
- '@dbal.conn'
- '@dispatcher'
- '@event_dispatcher'
- '@language'
- '@request'
- '@storage.attachment'

View file

@ -41,7 +41,7 @@ services:
arguments:
- '@text_formatter.data_access'
- '@cache.driver'
- '@dispatcher'
- '@event_dispatcher'
- '@config'
- '@text_formatter.s9e.link_helper'
- '@log'
@ -67,7 +67,7 @@ services:
- '@cache.driver'
- '%text_formatter.cache.parser.key%'
- '@text_formatter.s9e.factory'
- '@dispatcher'
- '@event_dispatcher'
text_formatter.s9e.quote_helper:
class: phpbb\textformatter\s9e\quote_helper
@ -83,7 +83,7 @@ services:
- '%text_formatter.cache.dir%'
- '%text_formatter.cache.renderer.key%'
- '@text_formatter.s9e.factory'
- '@dispatcher'
- '@event_dispatcher'
calls:
- [configure_mention_helper, ['@text_formatter.s9e.mention_helper']]
- [configure_quote_helper, ['@text_formatter.s9e.quote_helper']]

View file

@ -11,7 +11,7 @@ services:
- '%core.template.cache_path%'
- '@ext.manager'
- '@template.twig.loader'
- '@dispatcher'
- '@event_dispatcher'
- []
calls:
- [setLexer, ['@template.twig.lexer']]

View file

@ -4,7 +4,7 @@ services:
arguments:
- '@config'
- '@dbal.conn'
- '@dispatcher'
- '@event_dispatcher'
- '@controller.helper'
- '@language'
- '@log'

View file

@ -2,7 +2,7 @@ services:
acl.permissions:
class: phpbb\permissions
arguments:
- '@dispatcher'
- '@event_dispatcher'
- '@user'
user:

View file

@ -45,7 +45,7 @@ function register_compatibility_globals()
// Instantiate some basic classes
/* @var $phpbb_dispatcher \phpbb\event\dispatcher */
$phpbb_dispatcher = $phpbb_container->get('dispatcher');
$phpbb_dispatcher = $phpbb_container->get('event_dispatcher');
/* @var $request \phpbb\request\request_interface */
$request = $phpbb_container->get('request');

View file

@ -47,7 +47,7 @@ $template->set_custom_style(array(
), $paths);
/** @var $phpbb_dispatcher \phpbb\event\dispatcher */
$phpbb_dispatcher = $phpbb_installer_container->get('dispatcher');
$phpbb_dispatcher = $phpbb_installer_container->get('event_dispatcher');
/** @var \phpbb\language\language $language */
$language = $phpbb_installer_container->get('language');

View file

@ -50,6 +50,6 @@ $language = $phpbb_installer_container->get('language');
$language->add_lang(array('common', 'acp/common', 'acp/board', 'install', 'posting', 'cli'));
$application = new \phpbb\console\application('phpBB Installer', PHPBB_VERSION, $language, $config);
$application->setDispatcher($phpbb_installer_container->get('dispatcher'));
$application->setDispatcher($phpbb_installer_container->get('event_dispatcher'));
$application->register_container_commands($phpbb_installer_container->get('console.installer.command_collection'));
$application->run($input);

View file

@ -261,9 +261,9 @@ class migrator
*/
public function update()
{
$this->container->get('dispatcher')->disable();
$this->container->get('event_dispatcher')->disable();
$this->update_do();
$this->container->get('dispatcher')->enable();
$this->container->get('event_dispatcher')->enable();
}
/**
@ -509,9 +509,9 @@ class migrator
*/
public function revert($migration)
{
$this->container->get('dispatcher')->disable();
$this->container->get('event_dispatcher')->disable();
$this->revert_do($migration);
$this->container->get('dispatcher')->enable();
$this->container->get('event_dispatcher')->enable();
}
/**

View file

@ -205,11 +205,11 @@ class container_builder
// Mark all services public
$this->container->addCompilerPass(new pass\markpublic_pass());
// Event listeners "phpBB style"
$this->container->addCompilerPass(new RegisterListenersPass('dispatcher', 'event.listener_listener', 'event.listener'));
// Convert old event dispatcher syntax
$this->container->addCompilerPass(new pass\convert_events());
// Event listeners "Symfony style"
$this->container->addCompilerPass(new RegisterListenersPass('dispatcher'));
// Event listeners
$this->container->addCompilerPass(new RegisterListenersPass());
if ($this->use_extensions)
{

View file

@ -0,0 +1,51 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
namespace phpbb\di\pass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Converts event types to Symfony ones
*/
class convert_events implements CompilerPassInterface
{
/** @var string[] Map for conversions of types */
private static array $conversions = [
'event.listener_listener' => 'kernel.event_listener',
'event.listener' => 'kernel.event_subscriber',
];
/**
* Modify the container before it is passed to the rest of the code
* Add Symfony event tags to previously used phpBB ones
*
* @param ContainerBuilder $container ContainerBuilder object
* @return void
*/
public function process(ContainerBuilder $container): void
{
// Add alias for event dispatcher
$container->addAliases(['dispatcher' => 'event_dispatcher']);
foreach (self::$conversions as $from => $to)
{
foreach ($container->findTaggedServiceIds($from, true) as $id => $tags)
{
$definition = $container->getDefinition($id);
$definition->addTag($to);
}
}
}
}

View file

@ -120,7 +120,7 @@ class create_search_index extends database_task
$this->db = $container->get('dbal.conn');
$this->iohandler = $iohandler;
$this->installer_config = $config;
$this->phpbb_dispatcher = $container->get('dispatcher');
$this->phpbb_dispatcher = $container->get('event_dispatcher');
$this->user = $container->get('user');
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;

View file

@ -80,7 +80,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
new \phpbb\db\migration\helper()
);
$container->set('migrator', $this->migrator);
$container->set('dispatcher', new phpbb_mock_event_dispatcher());
$container->set('event_dispatcher', new phpbb_mock_event_dispatcher());
$this->extension_manager = new \phpbb\extension\manager(
$container,

View file

@ -117,7 +117,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$phpEx
)
);
$phpbb_container->set('dispatcher', $this->phpbb_dispatcher);
$phpbb_container->set('event_dispatcher', $this->phpbb_dispatcher);
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
$phpbb_container->setParameter('core.php_ext', $phpEx);
$phpbb_container->setParameter('tables.notifications', 'phpbb_notifications');

View file

@ -84,7 +84,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
$phpbb_container->set('cache.driver', $cache_driver);
$phpbb_container->set('cache', $cache);
$phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils());
$phpbb_container->set('dispatcher', $this->phpbb_dispatcher);
$phpbb_container->set('event_dispatcher', $this->phpbb_dispatcher);
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
$phpbb_container->setParameter('core.php_ext', $phpEx);
$phpbb_container->setParameter('tables.notifications', 'phpbb_notifications');

View file

@ -146,7 +146,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$phpEx
)
);
$phpbb_container->set('dispatcher', $phpbb_dispatcher);
$phpbb_container->set('event_dispatcher', $phpbb_dispatcher);
$phpbb_container->set('storage.attachment', $storage);
$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
$phpbb_container->setParameter('core.php_ext', $phpEx);

View file

@ -286,7 +286,7 @@ class phpbb_functional_test_case extends phpbb_test_case
);
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$container->set('migrator', $migrator);
$container->set('dispatcher', $phpbb_dispatcher);
$container->set('event_dispatcher', $phpbb_dispatcher);
$cache = $this->getMockBuilder('\phpbb\cache\service')
->setConstructorArgs([$this->get_cache_driver(), $config, $this->db, $phpbb_dispatcher, $phpbb_root_path, $phpEx])
->setMethods(['deferred_purge'])

View file

@ -503,9 +503,9 @@ class phpbb_test_case_helpers
}
// Create an event dispatcher
if ($container->has('dispatcher'))
if ($container->has('event_dispatcher'))
{
$dispatcher = $container->get('dispatcher');
$dispatcher = $container->get('event_dispatcher');
}
else if (isset($phpbb_dispatcher))
{