Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[FrameworkBundle] deprecate notifier service aliases that dont follow the convention #44053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2486,42 +2486,42 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $

$classToServices = [
AllMySmsTransportFactory::class => 'notifier.transport_factory.all-my-sms',
AmazonSnsTransportFactory::class => 'notifier.transport_factory.amazonsns',
AmazonSnsTransportFactory::class => 'notifier.transport_factory.amazon-sns',
ClickatellTransportFactory::class => 'notifier.transport_factory.clickatell',
DiscordTransportFactory::class => 'notifier.transport_factory.discord',
EsendexTransportFactory::class => 'notifier.transport_factory.esendex',
ExpoTransportFactory::class => 'notifier.transport_factory.expo',
FakeChatTransportFactory::class => 'notifier.transport_factory.fakechat',
FakeSmsTransportFactory::class => 'notifier.transport_factory.fakesms',
FakeChatTransportFactory::class => 'notifier.transport_factory.fake-chat',
FakeSmsTransportFactory::class => 'notifier.transport_factory.fake-sms',
FirebaseTransportFactory::class => 'notifier.transport_factory.firebase',
FreeMobileTransportFactory::class => 'notifier.transport_factory.freemobile',
FreeMobileTransportFactory::class => 'notifier.transport_factory.free-mobile',
GatewayApiTransportFactory::class => 'notifier.transport_factory.gateway-api',
GitterTransportFactory::class => 'notifier.transport_factory.gitter',
GoogleChatTransportFactory::class => 'notifier.transport_factory.googlechat',
GoogleChatTransportFactory::class => 'notifier.transport_factory.google-chat',
InfobipTransportFactory::class => 'notifier.transport_factory.infobip',
IqsmsTransportFactory::class => 'notifier.transport_factory.iqsms',
LightSmsTransportFactory::class => 'notifier.transport_factory.lightsms',
LinkedInTransportFactory::class => 'notifier.transport_factory.linkedin',
LightSmsTransportFactory::class => 'notifier.transport_factory.light-sms',
LinkedInTransportFactory::class => 'notifier.transport_factory.linked-in',
MailjetNotifierTransportFactory::class => 'notifier.transport_factory.mailjet',
MattermostTransportFactory::class => 'notifier.transport_factory.mattermost',
MercureTransportFactory::class => 'notifier.transport_factory.mercure',
MessageBirdTransport::class => 'notifier.transport_factory.messagebird',
MessageMediaTransportFactory::class => 'notifier.transport_factory.messagemedia',
MicrosoftTeamsTransportFactory::class => 'notifier.transport_factory.microsoftteams',
MessageBirdTransport::class => 'notifier.transport_factory.message-bird',
MessageMediaTransportFactory::class => 'notifier.transport_factory.message-media',
MicrosoftTeamsTransportFactory::class => 'notifier.transport_factory.microsoft-teams',
MobytTransportFactory::class => 'notifier.transport_factory.mobyt',
NexmoTransportFactory::class => 'notifier.transport_factory.nexmo',
OctopushTransportFactory::class => 'notifier.transport_factory.octopush',
OneSignalTransportFactory::class => 'notifier.transport_factory.onesignal',
OvhCloudTransportFactory::class => 'notifier.transport_factory.ovhcloud',
RocketChatTransportFactory::class => 'notifier.transport_factory.rocketchat',
OneSignalTransportFactory::class => 'notifier.transport_factory.one-signal',
OvhCloudTransportFactory::class => 'notifier.transport_factory.ovh-cloud',
RocketChatTransportFactory::class => 'notifier.transport_factory.rocket-chat',
SendinblueNotifierTransportFactory::class => 'notifier.transport_factory.sendinblue',
SinchTransportFactory::class => 'notifier.transport_factory.sinch',
SlackTransportFactory::class => 'notifier.transport_factory.slack',
Sms77TransportFactory::class => 'notifier.transport_factory.sms77',
SmsapiTransportFactory::class => 'notifier.transport_factory.smsapi',
SmsBiurasTransportFactory::class => 'notifier.transport_factory.smsbiuras',
SmsBiurasTransportFactory::class => 'notifier.transport_factory.sms-biuras',
SmscTransportFactory::class => 'notifier.transport_factory.smsc',
SpotHitTransportFactory::class => 'notifier.transport_factory.spothit',
SpotHitTransportFactory::class => 'notifier.transport_factory.spot-hit',
TelegramTransportFactory::class => 'notifier.transport_factory.telegram',
TelnyxTransportFactory::class => 'notifier.transport_factory.telnyx',
TurboSmsTransport::class => 'notifier.transport_factory.turbo-sms',
Expand All @@ -2533,27 +2533,11 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
$parentPackages = ['symfony/framework-bundle', 'symfony/notifier'];

foreach ($classToServices as $class => $service) {
switch ($package = substr($service, \strlen('notifier.transport_factory.'))) {
case 'amazonsns': $package = 'amazon-sns'; break;
case 'fakechat': $package = 'fake-chat'; break;
case 'fakesms': $package = 'fake-sms'; break;
case 'freemobile': $package = 'free-mobile'; break;
case 'googlechat': $package = 'google-chat'; break;
case 'lightsms': $package = 'light-sms'; break;
case 'linkedin': $package = 'linked-in'; break;
case 'messagebird': $package = 'message-bird'; break;
case 'messagemedia': $package = 'message-media'; break;
case 'microsoftteams': $package = 'microsoft-teams'; break;
case 'onesignal': $package = 'one-signal'; break;
case 'ovhcloud': $package = 'ovh-cloud'; break;
case 'rocketchat': $package = 'rocket-chat'; break;
case 'smsbiuras': $package = 'sms-biuras'; break;
case 'spothit': $package = 'spot-hit'; break;
case 'turbosms': $package = 'turbo-sms'; break;
}
$package = substr($service, \strlen('notifier.transport_factory.'));

if (!ContainerBuilder::willBeAvailable(sprintf('symfony/%s-notifier', $package), $class, $parentPackages, true)) {
$container->removeDefinition($service);
$container->removeAlias(str_replace('-', '', $service)); // @deprecated to be removed in 6.0
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,29 @@

return static function (ContainerConfigurator $container) {
$container->services()
->alias('notifier.transport_factory.fakechat', 'notifier.transport_factory.fake-chat')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.fake-chat" instead.')
->alias('notifier.transport_factory.fakesms', 'notifier.transport_factory.fake-sms')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.fake-sms" instead.')
->alias('notifier.transport_factory.freemobile', 'notifier.transport_factory.free-mobile')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.free-mobile" instead.')
->alias('notifier.transport_factory.googlechat', 'notifier.transport_factory.google-chat')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.google-chat" instead.')
->alias('notifier.transport_factory.lightsms', 'notifier.transport_factory.light-sms')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.light-sms" instead.')
->alias('notifier.transport_factory.linkedin', 'notifier.transport_factory.linked-in')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.linked-in" instead.')
->alias('notifier.transport_factory.microsoftteams', 'notifier.transport_factory.microsoft-teams')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.microsoft-teams" instead.')
->alias('notifier.transport_factory.onesignal', 'notifier.transport_factory.one-signal')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.one-signal" instead.')
->alias('notifier.transport_factory.ovhcloud', 'notifier.transport_factory.ovh-cloud')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.ovh-cloud" instead.')
->alias('notifier.transport_factory.rocketchat', 'notifier.transport_factory.rocket-chat')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.rocket-chat" instead.')
->alias('notifier.transport_factory.spothit', 'notifier.transport_factory.spot-hit')
->deprecate('symfony/framework-bundle', '5.4', 'The "%alias_id% service is deprecated, use "notifier.transport_factory.spot-hit" instead.')

->set('notifier.transport_factory.abstract', AbstractTransportFactory::class)
->abstract()
->args([service('event_dispatcher'), service('http_client')->ignoreOnInvalid()])
Expand All @@ -67,7 +90,7 @@
->parent('notifier.transport_factory.abstract')
->tag('chatter.transport_factory')

->set('notifier.transport_factory.linkedin', LinkedInTransportFactory::class)
->set('notifier.transport_factory.linked-in', LinkedInTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('chatter.transport_factory')

Expand All @@ -83,11 +106,11 @@
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.rocketchat', RocketChatTransportFactory::class)
->set('notifier.transport_factory.rocket-chat', RocketChatTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('chatter.transport_factory')

->set('notifier.transport_factory.googlechat', GoogleChatTransportFactory::class)
->set('notifier.transport_factory.google-chat', GoogleChatTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('chatter.transport_factory')

Expand All @@ -103,23 +126,23 @@
->parent('notifier.transport_factory.abstract')
->tag('chatter.transport_factory')

->set('notifier.transport_factory.freemobile', FreeMobileTransportFactory::class)
->set('notifier.transport_factory.free-mobile', FreeMobileTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.spothit', SpotHitTransportFactory::class)
->set('notifier.transport_factory.spot-hit', SpotHitTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.fakechat', FakeChatTransportFactory::class)
->set('notifier.transport_factory.fake-chat', FakeChatTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('chatter.transport_factory')

->set('notifier.transport_factory.fakesms', FakeSmsTransportFactory::class)
->set('notifier.transport_factory.fake-sms', FakeSmsTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.ovhcloud', OvhCloudTransportFactory::class)
->set('notifier.transport_factory.ovh-cloud', OvhCloudTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

Expand Down Expand Up @@ -163,7 +186,7 @@
->parent('notifier.transport_factory.abstract')
->tag('chatter.transport_factory')

->set('notifier.transport_factory.microsoftteams', MicrosoftTeamsTransportFactory::class)
->set('notifier.transport_factory.microsoft-teams', MicrosoftTeamsTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('chatter.transport_factory')

Expand All @@ -183,7 +206,7 @@
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.amazonsns', AmazonSnsTransportFactory::class)
->set('notifier.transport_factory.amazon-sns', AmazonSnsTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')
->tag('chatter.transport_factory')
Expand All @@ -193,23 +216,23 @@
->tag('chatter.transport_factory')
->tag('texter.transport_factory')

->set('notifier.transport_factory.lightsms', LightSmsTransportFactory::class)
->set('notifier.transport_factory.light-sms', LightSmsTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.smsbiuras', SmsBiurasTransportFactory::class)
->set('notifier.transport_factory.sms-biuras', SmsBiurasTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.smsc', SmscTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.messagebird', MessageBirdTransportFactory::class)
->set('notifier.transport_factory.message-bird', MessageBirdTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.messagemedia', MessageMediaTransportFactory::class)
->set('notifier.transport_factory.message-media', MessageMediaTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

Expand All @@ -233,7 +256,7 @@
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

->set('notifier.transport_factory.onesignal', OneSignalTransportFactory::class)
->set('notifier.transport_factory.one-signal', OneSignalTransportFactory::class)
->parent('notifier.transport_factory.abstract')
->tag('texter.transport_factory')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1984,7 +1984,7 @@ public function testIfNotifierTransportsAreKnownByFrameworkExtension()
$container = $this->createContainerFromFile('notifier');

foreach ((new Finder())->in(\dirname(__DIR__, 4).'/Component/Notifier/Bridge')->directories()->depth(0)->exclude('Mercure') as $bridgeDirectory) {
$transportFactoryName = strtolower($bridgeDirectory->getFilename());
$transportFactoryName = strtolower(preg_replace('/(.)([A-Z])/', '$1-$2', $bridgeDirectory->getFilename()));
$this->assertTrue($container->hasDefinition('notifier.transport_factory.'.$transportFactoryName), sprintf('Did you forget to add the TransportFactory: "%s" to the $classToServices array in the FrameworkBundleExtension?', $bridgeDirectory->getFilename()));
}
}
Expand Down