Skip to content

Commit

Permalink
Remove Interface suffix and use specific prefix form default impl
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Dec 29, 2021
1 parent aab81ba commit 5174e26
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 14 deletions.
8 changes: 8 additions & 0 deletions UPGRADE-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ The `@NucleosProfileBundle/Resources/config/routing/all.xml` routing configurati

All listeneres are now registered by default. The `use_authentication_listener`, `use_listener` and `use_flash_notifications` configuration keys were removed.

## Removed `Interface` suffix

The `Interface` suffix was removed from all interfaces. All default implementation use specific class prefix.

- `Nucleos\ProfileBundle\Mailer\MailerInterface` => `Nucleos\ProfileBundle\Mailer\RegistrationMailer`
- `Nucleos\ProfileBundle\Mailer\NoopMailer` => `Nucleos\ProfileBundle\Mailer\NoopRegistrationMailer`
- `Nucleos\ProfileBundle\Mailer\Mailer` => `Nucleos\ProfileBundle\Mailer\SimpleRegistrationMailer`
-
## Deprecations

All the deprecated code introduced on 1.8.x is removed on 2.0.
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ All available configuration options are listed below with their default values.
from_email: ~ # Required
enabled: false # change to true for required email confirmation
service:
mailer: nucleos_profile.mailer.default
mailer: nucleos_profile.mailer.simple
2 changes: 1 addition & 1 deletion docs/mailing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Default Mailer Implementations
The bundle comes with three mailer implementations. They are listed below
by service id:

- ``nucleos_profile.mailer.default`` is the default implementation, and uses symfony mailer to send emails.
- ``nucleos_profile.mailer.simple`` is the default implementation, and uses symfony mailer to send emails.
- ``nucleos_profile.mailer.noop`` is a mailer implementation which performs no operation, so no emails are sent.

Configuring the Sender Email Address
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private function addServiceSection(ArrayNodeDefinition $node): void
->arrayNode('service')
->addDefaultsIfNotSet()
->children()
->scalarNode('mailer')->defaultValue('nucleos_profile.mailer.default')->end()
->scalarNode('mailer')->defaultValue('nucleos_profile.mailer.simple')->end()
->end()
->end()
->end()
Expand Down
6 changes: 3 additions & 3 deletions src/EventListener/EmailConfirmationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Nucleos\ProfileBundle\EventListener;

use Nucleos\ProfileBundle\Event\UserFormEvent;
use Nucleos\ProfileBundle\Mailer\MailerInterface;
use Nucleos\ProfileBundle\Mailer\RegistrationMailer;
use Nucleos\ProfileBundle\NucleosProfileEvents;
use Nucleos\UserBundle\Util\TokenGenerator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand All @@ -22,7 +22,7 @@

final class EmailConfirmationListener implements EventSubscriberInterface
{
private MailerInterface $mailer;
private RegistrationMailer $mailer;

private TokenGenerator $tokenGenerator;

Expand All @@ -31,7 +31,7 @@ final class EmailConfirmationListener implements EventSubscriberInterface
private SessionInterface $session;

public function __construct(
MailerInterface $mailer,
RegistrationMailer $mailer,
TokenGenerator $tokenGenerator,
UrlGeneratorInterface $router,
SessionInterface $session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* It is used when the 'email' configuration is not set,
* and allows to use this bundle without swiftmailer.
*/
final class NoopMailer implements MailerInterface
final class NoopRegistrationMailer implements RegistrationMailer
{
public function sendConfirmationEmailMessage(UserInterface $user): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Nucleos\UserBundle\Model\UserInterface;

interface MailerInterface
interface RegistrationMailer
{
/**
* Send an email to a user to confirm the account creation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

final class Mailer implements MailerInterface
final class SimpleRegistrationMailer implements RegistrationMailer
{
private SymfonyMailer $mailer;

Expand Down
8 changes: 4 additions & 4 deletions src/Resources/config/mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Nucleos\ProfileBundle\Mailer\Mailer;
use Nucleos\ProfileBundle\Mailer\NoopMailer;
use Nucleos\ProfileBundle\Mailer\NoopRegistrationMailer;
use Nucleos\ProfileBundle\Mailer\SimpleRegistrationMailer;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Reference;

return static function (ContainerConfigurator $container): void {
$container->services()

->set('nucleos_profile.mailer.default', Mailer::class)
->set('nucleos_profile.mailer.simple', SimpleRegistrationMailer::class)
->args([
new Reference('mailer.mailer'),
new Reference('translator'),
new Reference('router'),
new Parameter('nucleos_profile.registration.confirmation.from_email'),
])

->set('nucleos_profile.mailer.noop', NoopMailer::class)
->set('nucleos_profile.mailer.noop', NoopRegistrationMailer::class)

;
};
2 changes: 1 addition & 1 deletion tests/DependencyInjection/NucleosProfileExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testUserLoadUtilServiceWithDefaults(): void
{
$this->createEmptyConfiguration();

$this->assertAlias('nucleos_profile.mailer.default', 'nucleos_profile.mailer');
$this->assertAlias('nucleos_profile.mailer.simple', 'nucleos_profile.mailer');
}

public function testUserLoadUtilService(): void
Expand Down

0 comments on commit 5174e26

Please sign in to comment.