Skip to content

Commit 5fee6ef

Browse files
Merge branch '5.4' into 6.0
* 5.4: [Security] Do not overwrite already stored tokens for REMOTE_USER authentication [Validator] Fix validation for single level domains [Notifier] add Vonage bridge to replace the Nexmo one Fix redundant type casts Increased the reserved memory from 10k to 32k Complete event name & dispatcher in EventDispatcherDebugCommand [DoctrineBridge] Add DbalLoggerTest to group legacy Leverage DBAL's getNativeConnection() method [FrameworkBundle] Fix property-info phpstan extractor discovery Fix idempotency of LocoProvider write method
2 parents 0c0fd35 + 38fabed commit 5fee6ef

File tree

4 files changed

+108
-1
lines changed

4 files changed

+108
-1
lines changed

Command/EventDispatcherDebugCommand.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@
1515
use Symfony\Bundle\FrameworkBundle\Console\Helper\DescriptorHelper;
1616
use Symfony\Component\Console\Attribute\AsCommand;
1717
use Symfony\Component\Console\Command\Command;
18+
use Symfony\Component\Console\Completion\CompletionInput;
19+
use Symfony\Component\Console\Completion\CompletionSuggestions;
1820
use Symfony\Component\Console\Input\InputArgument;
1921
use Symfony\Component\Console\Input\InputInterface;
2022
use Symfony\Component\Console\Input\InputOption;
2123
use Symfony\Component\Console\Output\OutputInterface;
2224
use Symfony\Component\Console\Style\SymfonyStyle;
2325
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
26+
use Symfony\Contracts\Service\ServiceProviderInterface;
2427

2528
/**
2629
* A console command for retrieving information about event dispatcher.
@@ -119,6 +122,31 @@ protected function execute(InputInterface $input, OutputInterface $output): int
119122
return 0;
120123
}
121124

125+
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
126+
{
127+
if ($input->mustSuggestArgumentValuesFor('event')) {
128+
$dispatcherServiceName = $input->getOption('dispatcher');
129+
if ($this->dispatchers->has($dispatcherServiceName)) {
130+
$dispatcher = $this->dispatchers->get($dispatcherServiceName);
131+
$suggestions->suggestValues(array_keys($dispatcher->getListeners()));
132+
}
133+
134+
return;
135+
}
136+
137+
if ($input->mustSuggestOptionValuesFor('dispatcher')) {
138+
if ($this->dispatchers instanceof ServiceProviderInterface) {
139+
$suggestions->suggestValues(array_keys($this->dispatchers->getProvidedServices()));
140+
}
141+
142+
return;
143+
}
144+
145+
if ($input->mustSuggestOptionValuesFor('format')) {
146+
$suggestions->suggestValues((new DescriptorHelper())->getFormats());
147+
}
148+
}
149+
122150
private function searchForEvent(EventDispatcherInterface $dispatcher, string $needle): array
123151
{
124152
$output = [];

DependencyInjection/FrameworkExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\Common\Annotations\Reader;
1616
use Http\Client\HttpClient;
1717
use phpDocumentor\Reflection\DocBlockFactoryInterface;
18+
use phpDocumentor\Reflection\Types\ContextFactory;
1819
use PHPStan\PhpDocParser\Parser\PhpDocParser;
1920
use Psr\Cache\CacheItemPoolInterface;
2021
use Psr\Container\ContainerInterface as PsrContainerInterface;
@@ -151,6 +152,7 @@
151152
use Symfony\Component\Notifier\Bridge\Telnyx\TelnyxTransportFactory;
152153
use Symfony\Component\Notifier\Bridge\TurboSms\TurboSmsTransport;
153154
use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory;
155+
use Symfony\Component\Notifier\Bridge\Vonage\VonageTransportFactory;
154156
use Symfony\Component\Notifier\Bridge\Yunpian\YunpianTransportFactory;
155157
use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory;
156158
use Symfony\Component\Notifier\Notifier;
@@ -1779,7 +1781,7 @@ private function registerPropertyInfoConfiguration(ContainerBuilder $container,
17791781

17801782
if (
17811783
ContainerBuilder::willBeAvailable('phpstan/phpdoc-parser', PhpDocParser::class, ['symfony/framework-bundle', 'symfony/property-info'])
1782-
&& ContainerBuilder::willBeAvailable('phpdocumentor/type-resolver', PhpDocParser::class, ['symfony/framework-bundle', 'symfony/property-info'])
1784+
&& ContainerBuilder::willBeAvailable('phpdocumentor/type-resolver', ContextFactory::class, ['symfony/framework-bundle', 'symfony/property-info'])
17831785
) {
17841786
$definition = $container->register('property_info.phpstan_extractor', PhpStanExtractor::class);
17851787
$definition->addTag('property_info.type_extractor', ['priority' => -1000]);
@@ -2434,6 +2436,7 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
24342436
TelnyxTransportFactory::class => 'notifier.transport_factory.telnyx',
24352437
TurboSmsTransport::class => 'notifier.transport_factory.turbo-sms',
24362438
TwilioTransportFactory::class => 'notifier.transport_factory.twilio',
2439+
VonageTransportFactory::class => 'notifier.transport_factory.vonage',
24372440
YunpianTransportFactory::class => 'notifier.transport_factory.yunpian',
24382441
ZulipTransportFactory::class => 'notifier.transport_factory.zulip',
24392442
];

Resources/config/notifier_transports.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
use Symfony\Component\Notifier\Bridge\Telnyx\TelnyxTransportFactory;
5353
use Symfony\Component\Notifier\Bridge\TurboSms\TurboSmsTransportFactory;
5454
use Symfony\Component\Notifier\Bridge\Twilio\TwilioTransportFactory;
55+
use Symfony\Component\Notifier\Bridge\Vonage\VonageTransportFactory;
5556
use Symfony\Component\Notifier\Bridge\Yunpian\YunpianTransportFactory;
5657
use Symfony\Component\Notifier\Bridge\Zulip\ZulipTransportFactory;
5758
use Symfony\Component\Notifier\Transport\AbstractTransportFactory;
@@ -83,6 +84,11 @@
8384
->set('notifier.transport_factory.nexmo', NexmoTransportFactory::class)
8485
->parent('notifier.transport_factory.abstract')
8586
->tag('texter.transport_factory')
87+
->deprecate('symfony/framework-bundle', '5.4', 'The "%service_id% service is deprecated, use "notifier.transport_factory.vonage" instead.')
88+
89+
->set('notifier.transport_factory.vonage', VonageTransportFactory::class)
90+
->parent('notifier.transport_factory.abstract')
91+
->tag('texter.transport_factory')
8692

8793
->set('notifier.transport_factory.rocket-chat', RocketChatTransportFactory::class)
8894
->parent('notifier.transport_factory.abstract')
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bundle\FrameworkBundle\Command\EventDispatcherDebugCommand;
16+
use Symfony\Component\Console\Tester\CommandCompletionTester;
17+
use Symfony\Component\DependencyInjection\ServiceLocator;
18+
use Symfony\Component\EventDispatcher\EventDispatcher;
19+
20+
class EventDispatcherDebugCommandTest extends TestCase
21+
{
22+
/**
23+
* @dataProvider provideCompletionSuggestions
24+
*/
25+
public function testComplete(array $input, array $expectedSuggestions)
26+
{
27+
$tester = $this->createCommandCompletionTester();
28+
29+
$suggestions = $tester->complete($input);
30+
31+
$this->assertSame($expectedSuggestions, $suggestions);
32+
}
33+
34+
public function provideCompletionSuggestions()
35+
{
36+
yield 'event' => [[''], ['Symfony\Component\Mailer\Event\MessageEvent', 'console.command']];
37+
yield 'event for other dispatcher' => [['--dispatcher', 'other_event_dispatcher', ''], ['other_event', 'App\OtherEvent']];
38+
yield 'dispatcher' => [['--dispatcher='], ['event_dispatcher', 'other_event_dispatcher']];
39+
yield 'format' => [['--format='], ['txt', 'xml', 'json', 'md']];
40+
}
41+
42+
private function createCommandCompletionTester(): CommandCompletionTester
43+
{
44+
$dispatcher = new EventDispatcher();
45+
$otherDispatcher = new EventDispatcher();
46+
47+
$dispatcher->addListener('event', 'Listener');
48+
$otherDispatcher->addListener('other_event', 'OtherListener');
49+
50+
$dispatchers = new ServiceLocator([
51+
'event_dispatcher' => function () {
52+
$dispatcher = new EventDispatcher();
53+
$dispatcher->addListener('Symfony\Component\Mailer\Event\MessageEvent', 'var_dump');
54+
$dispatcher->addListener('console.command', 'var_dump');
55+
56+
return $dispatcher;
57+
},
58+
'other_event_dispatcher' => function () {
59+
$dispatcher = new EventDispatcher();
60+
$dispatcher->addListener('other_event', 'var_dump');
61+
$dispatcher->addListener('App\OtherEvent', 'var_dump');
62+
63+
return $dispatcher;
64+
},
65+
]);
66+
$command = new EventDispatcherDebugCommand($dispatchers);
67+
68+
return new CommandCompletionTester($command);
69+
}
70+
}

0 commit comments

Comments
 (0)