Skip to content

Commit d68c845

Browse files
committed
Move event alias mappings to their components.
1 parent 76cac84 commit d68c845

File tree

2 files changed

+15
-53
lines changed

2 files changed

+15
-53
lines changed

Resources/config/services.php

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
use Symfony\Bundle\FrameworkBundle\HttpCache\HttpCache;
1515
use Symfony\Component\Config\Resource\SelfCheckingResourceChecker;
1616
use Symfony\Component\Config\ResourceCheckerConfigCacheFactory;
17-
use Symfony\Component\Console\Event\ConsoleCommandEvent;
18-
use Symfony\Component\Console\Event\ConsoleErrorEvent;
19-
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
17+
use Symfony\Component\Console\ConsoleEvents;
2018
use Symfony\Component\DependencyInjection\Config\ContainerParametersResourceChecker;
2119
use Symfony\Component\DependencyInjection\EnvVarProcessor;
2220
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBag;
@@ -26,70 +24,34 @@
2624
use Symfony\Component\EventDispatcher\EventDispatcher;
2725
use Symfony\Component\EventDispatcher\EventDispatcherInterface as EventDispatcherInterfaceComponentAlias;
2826
use Symfony\Component\Filesystem\Filesystem;
29-
use Symfony\Component\Form\Event\PostSetDataEvent;
30-
use Symfony\Component\Form\Event\PostSubmitEvent;
31-
use Symfony\Component\Form\Event\PreSetDataEvent;
32-
use Symfony\Component\Form\Event\PreSubmitEvent;
33-
use Symfony\Component\Form\Event\SubmitEvent;
27+
use Symfony\Component\Form\FormEvents;
3428
use Symfony\Component\HttpFoundation\RequestStack;
3529
use Symfony\Component\HttpFoundation\UrlHelper;
3630
use Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer;
3731
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate;
3832
use Symfony\Component\HttpKernel\Config\FileLocator;
3933
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
40-
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
41-
use Symfony\Component\HttpKernel\Event\ControllerEvent;
42-
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
43-
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
44-
use Symfony\Component\HttpKernel\Event\RequestEvent;
45-
use Symfony\Component\HttpKernel\Event\ResponseEvent;
46-
use Symfony\Component\HttpKernel\Event\TerminateEvent;
47-
use Symfony\Component\HttpKernel\Event\ViewEvent;
4834
use Symfony\Component\HttpKernel\EventListener\LocaleAwareListener;
4935
use Symfony\Component\HttpKernel\HttpCache\Store;
5036
use Symfony\Component\HttpKernel\HttpKernel;
5137
use Symfony\Component\HttpKernel\HttpKernelInterface;
38+
use Symfony\Component\HttpKernel\KernelEvents;
5239
use Symfony\Component\HttpKernel\KernelInterface;
5340
use Symfony\Component\HttpKernel\UriSigner;
5441
use Symfony\Component\String\LazyString;
5542
use Symfony\Component\String\Slugger\AsciiSlugger;
5643
use Symfony\Component\String\Slugger\SluggerInterface;
57-
use Symfony\Component\Workflow\Event\AnnounceEvent;
58-
use Symfony\Component\Workflow\Event\CompletedEvent;
59-
use Symfony\Component\Workflow\Event\EnteredEvent;
60-
use Symfony\Component\Workflow\Event\EnterEvent;
61-
use Symfony\Component\Workflow\Event\GuardEvent;
62-
use Symfony\Component\Workflow\Event\LeaveEvent;
63-
use Symfony\Component\Workflow\Event\TransitionEvent;
44+
use Symfony\Component\Workflow\WorkflowEvents;
6445
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
6546

6647
return static function (ContainerConfigurator $container) {
6748
// this parameter is used at compile time in RegisterListenersPass
68-
$container->parameters()->set('event_dispatcher.event_aliases', [
69-
ConsoleCommandEvent::class => 'console.command',
70-
ConsoleErrorEvent::class => 'console.error',
71-
ConsoleTerminateEvent::class => 'console.terminate',
72-
PreSubmitEvent::class => 'form.pre_submit',
73-
SubmitEvent::class => 'form.submit',
74-
PostSubmitEvent::class => 'form.post_submit',
75-
PreSetDataEvent::class => 'form.pre_set_data',
76-
PostSetDataEvent::class => 'form.post_set_data',
77-
ControllerArgumentsEvent::class => 'kernel.controller_arguments',
78-
ControllerEvent::class => 'kernel.controller',
79-
ResponseEvent::class => 'kernel.response',
80-
FinishRequestEvent::class => 'kernel.finish_request',
81-
RequestEvent::class => 'kernel.request',
82-
ViewEvent::class => 'kernel.view',
83-
ExceptionEvent::class => 'kernel.exception',
84-
TerminateEvent::class => 'kernel.terminate',
85-
GuardEvent::class => 'workflow.guard',
86-
LeaveEvent::class => 'workflow.leave',
87-
TransitionEvent::class => 'workflow.transition',
88-
EnterEvent::class => 'workflow.enter',
89-
EnteredEvent::class => 'workflow.entered',
90-
CompletedEvent::class => 'workflow.completed',
91-
AnnounceEvent::class => 'workflow.announce',
92-
]);
49+
$container->parameters()->set('event_dispatcher.event_aliases', array_merge(
50+
class_exists(ConsoleEvents::class) ? ConsoleEvents::ALIASES : [],
51+
class_exists(FormEvents::class) ? FormEvents::ALIASES : [],
52+
KernelEvents::ALIASES,
53+
class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES : []
54+
));
9355

9456
$container->services()
9557

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
"doctrine/cache": "~1.0",
3737
"symfony/asset": "^5.1",
3838
"symfony/browser-kit": "^4.4|^5.0",
39-
"symfony/console": "^4.4|^5.0",
39+
"symfony/console": "^5.2",
4040
"symfony/css-selector": "^4.4|^5.0",
4141
"symfony/dom-crawler": "^4.4|^5.0",
4242
"symfony/dotenv": "^5.1",
4343
"symfony/polyfill-intl-icu": "~1.0",
44-
"symfony/form": "^4.4|^5.0",
44+
"symfony/form": "^5.2",
4545
"symfony/expression-language": "^4.4|^5.0",
4646
"symfony/http-client": "^4.4|^5.0",
4747
"symfony/lock": "^4.4|^5.0",
@@ -58,7 +58,7 @@
5858
"symfony/translation": "^5.0",
5959
"symfony/twig-bundle": "^4.4|^5.0",
6060
"symfony/validator": "^4.4|^5.0",
61-
"symfony/workflow": "^4.4|^5.0",
61+
"symfony/workflow": "^5.2",
6262
"symfony/yaml": "^4.4|^5.0",
6363
"symfony/property-info": "^4.4|^5.0",
6464
"symfony/web-link": "^4.4|^5.0",
@@ -73,7 +73,7 @@
7373
"phpunit/phpunit": "<5.4.3",
7474
"symfony/asset": "<5.1",
7575
"symfony/browser-kit": "<4.4",
76-
"symfony/console": "<4.4",
76+
"symfony/console": "<5.2",
7777
"symfony/dotenv": "<5.1",
7878
"symfony/dom-crawler": "<4.4",
7979
"symfony/http-client": "<4.4",
@@ -90,7 +90,7 @@
9090
"symfony/twig-bundle": "<4.4",
9191
"symfony/validator": "<4.4",
9292
"symfony/web-profiler-bundle": "<4.4",
93-
"symfony/workflow": "<4.4"
93+
"symfony/workflow": "<5.2"
9494
},
9595
"suggest": {
9696
"ext-apcu": "For best performance of the system caches",

0 commit comments

Comments
 (0)