Skip to content

Commit

Permalink
bug #35826 [Notifier] Add correct tags for NullTransportFactory (jsch…
Browse files Browse the repository at this point in the history
…aedl)

This PR was merged into the 5.0 branch.

Discussion
----------

[Notifier] Add correct tags for NullTransportFactory

| Q             | A
| ------------- | ---
| Branch?       | 5.0
| Bug fix?      | yes
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tickets       | - <!-- prefix each issue number with "Fix #", if any -->
| License       | MIT
| Doc PR        | - <!-- required for new features -->

I tried to disable the delivery of notifications in `dev` environment with the following configuration:

```
framework:
    notifier:
        chatter_transports:
            slack: 'null://null'
        texter_transports:
            twilio: 'null://null'
        channel_policy:
            urgent: ['chat/slack', 'sms/twilio']
            high: ['email']
            medium: ['email']
            low: ['email']
```

While sending the notification like this:

```
$notification = (new Notification())
            ->subject('Test subject')
            ->importance(Notification::IMPORTANCE_URGENT)
            ->content('Test content')
;

$this->notifier->send($notification);
```

I got an `UnsupportedSchemeException`: The "null" scheme is not supported.

After some digging I figured out that this Exception occurred because the `NullTransportFactory` was not tagged with the `chatter.transport_factory` and `texter.transport_factory` tags. Which is the reason the `NullTransportFactory` was not injected in the `Transport` class and so the `NullTransport` couldn't be used.

This PR should fix this Bug.

Commits
-------

1ff5e3c [Notifier] Add correct tags for NullTransportFactory
  • Loading branch information
nicolas-grekas committed Feb 23, 2020
2 parents 93ccd28 + 1ff5e3c commit 03f525a
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -27,7 +27,8 @@
</service>

<service id="notifier.transport_factory.null" class="Symfony\Component\Notifier\Transport\NullTransportFactory" parent="notifier.transport_factory.abstract">
<tag name="notifier.transport_factory" />
<tag name="chatter.transport_factory" />
<tag name="texter.transport_factory" />
</service>
</services>
</container>

0 comments on commit 03f525a

Please sign in to comment.