Skip to content

[FrameworkBundle][Notifier] Allow to configure or disable the message bus to use #39353

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 2 commits into from
Dec 11, 2022

Conversation

jschaedl
Copy link
Contributor

@jschaedl jschaedl commented Dec 6, 2020

Q A
Branch? 6.3
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR tbd

For the mailer integration there is already a possibility to disable or configure the message_bus to use. See: #34633 and #34648

This PR introduces a similar config option notifier.message_bus for the notifier integration.

Things done:

  • Add a config option notifier.message_bus for the notifier configuration
  • Adjust FrameworkExtension considering the new message_bus config option
  • Add tests for the new config option

@carsonbot carsonbot changed the title [Frameworkbundle][Notifier] Allow to configure or disable the message bus to use [FrameworkBundle] [Frameworkbundle][Notifier] Allow to configure or disable the message bus to use Dec 6, 2020
@carsonbot carsonbot changed the title [FrameworkBundle] [Frameworkbundle][Notifier] Allow to configure or disable the message bus to use [FrameworkBundle][Notifier] [Frameworkbundle] Allow to configure or disable the message bus to use Dec 6, 2020
@jschaedl jschaedl force-pushed the notifier-disable-message-bus branch 2 times, most recently from 4e9a72c to d7f207a Compare December 6, 2020 15:35
@jderusse jderusse added this to the 5.x milestone Dec 6, 2020
@OskarStark
Copy link
Contributor

It looks like your commit is not associated with your GitHub account:
image

And FrameworkBundle is twice in the PR header 🧐

@nicolas-grekas nicolas-grekas changed the title [FrameworkBundle][Notifier] [Frameworkbundle] Allow to configure or disable the message bus to use [FrameworkBundle][Notifier] Allow to configure or disable the message bus to use Dec 10, 2020
@OskarStark
Copy link
Contributor

Anything left todo here @jschaedl ?

@jschaedl
Copy link
Contributor Author

jschaedl commented Jan 31, 2021

Hi @OskarStark
Implementation is done. But I have no idea why tests are failing on PHP 7.4 🤔

@OskarStark
Copy link
Contributor

Can you please rebase and see if it's still failing ? Thanks

@jschaedl jschaedl force-pushed the notifier-disable-message-bus branch 2 times, most recently from 0952835 to 13a1266 Compare January 31, 2021 13:16
@OskarStark
Copy link
Contributor

@jschaedl can you please check the failing tests?

Thanks

@jschaedl jschaedl force-pushed the notifier-disable-message-bus branch 2 times, most recently from fe8b2ac to 2e8cd93 Compare April 6, 2021 12:31
@jschaedl
Copy link
Contributor Author

jschaedl commented Apr 6, 2021

@OskarStark I rebased the branch. Tests are still failing on PHP 8.0 but this seems to be unrelated with my changes.

@OskarStark OskarStark requested a review from jderusse April 6, 2021 14:05
@nicolas-grekas
Copy link
Member

The failures are related I believe.

@jschaedl jschaedl force-pushed the notifier-disable-message-bus branch 2 times, most recently from 61acd5c to 3e800b6 Compare April 17, 2021 06:20
@OskarStark
Copy link
Contributor

Please rebase to get rid of Travis, thanks

@jschaedl jschaedl force-pushed the notifier-disable-message-bus branch from 728afd7 to 616cdd6 Compare August 17, 2021 06:26
@jschaedl
Copy link
Contributor Author

@OskarStark Rebase done.

if ($container->hasDefinition($serviceId)) {
$container->getDefinition($serviceId)
->setArgument(0, null)
->replaceArgument(1, $messageBus ? new Reference($messageBus) : new Reference('messenger.default_bus', ContainerInterface::NULL_ON_INVALID_REFERENCE))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$messageBus ? ... can be removed because we are in the else part.

@chalasr
Copy link
Member

chalasr commented Aug 19, 2021

Some tests are failing

@@ -2390,6 +2390,24 @@ private function registerNotifierConfiguration(array $config, ContainerBuilder $
$container->removeDefinition('notifier.channel.email');
}

$servicesWithBusArgument = ['texter', 'chatter', 'notifier.channel.chat', 'notifier.channel.email', 'notifier.channel.sms'];
if (false === $messageBus = $config['message_bus']) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we throw an exception if one tries to configure message_bus while messenger is not installed/enabled?

Copy link
Contributor Author

@jschaedl jschaedl Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is used here for setting the messageBus argument on the mailer.mailer service in the same way. I thought using ContainerInterface::NULL_ON_INVALID_REFERENCE is enough?

@fabpot
Copy link
Member

fabpot commented Oct 19, 2021

@jschaedl Can you have a look at the failing tests?

@fabpot fabpot modified the milestones: 5.4, 6.1 Nov 16, 2021
@fabpot fabpot modified the milestones: 6.1, 6.2 May 20, 2022
@fabpot fabpot force-pushed the notifier-disable-message-bus branch from 77db22d to 95718bb Compare July 21, 2022 09:45
@fabpot
Copy link
Member

fabpot commented Jul 21, 2022

@jschaedl I've rebased on current 6.2 and fixed the tests. Can you review my commit before I merge?

foreach ($servicesWithBusArgument as $serviceId) {
if ($container->hasDefinition($serviceId)) {
$container->getDefinition($serviceId)
->setArgument(0, null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get why you are removing the transports here. We do need the transports in all cases.

Copy link
Contributor Author

@jschaedl jschaedl Nov 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean, but I am not removing the transports. I am adding the message bus service to every service with a messageBus argument, in case the message_bus config is filled.

@nicolas-grekas
Copy link
Member

Friendly ping @jschaedl

@nicolas-grekas nicolas-grekas modified the milestones: 6.2, 6.3 Nov 5, 2022
@jschaedl jschaedl force-pushed the notifier-disable-message-bus branch from 68f31ac to fc7aaa6 Compare November 9, 2022 19:57
@jschaedl
Copy link
Contributor Author

jschaedl commented Nov 9, 2022

I rebased again. Looks good to me now.

@fabpot
Copy link
Member

fabpot commented Dec 11, 2022

Thank you @jschaedl.

@fabpot fabpot merged commit c7f82de into symfony:6.3 Dec 11, 2022
@fabpot fabpot mentioned this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants