From 1f72e7b77ceed2c5e52bebc31450e56a0da36df5 Mon Sep 17 00:00:00 2001 From: Koen Eelen Date: Thu, 22 Aug 2024 10:55:15 +0200 Subject: [PATCH 1/2] Moved classes around --- app/{Mails => Domain/Mail}/Addresses.php | 2 +- app/Domain/Mail/Mailer.php | 1 - app/{Mails => MailJet}/MailManager.php | 3 ++- app/{Domain/Mail => MailJet}/MailjetConfig.php | 2 +- app/{Domain/Mail => MailJet}/MailjetMailer.php | 6 ++++-- .../MailjetServiceProvider.php} | 6 ++---- config/app.php | 2 +- tests/Mails/MailManagerTest.php | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) rename app/{Mails => Domain/Mail}/Addresses.php (87%) rename app/{Mails => MailJet}/MailManager.php (98%) rename app/{Domain/Mail => MailJet}/MailjetConfig.php (95%) rename app/{Domain/Mail => MailJet}/MailjetMailer.php (94%) rename app/{Mails/MailServiceProvider.php => MailJet/MailjetServiceProvider.php} (91%) diff --git a/app/Mails/Addresses.php b/app/Domain/Mail/Addresses.php similarity index 87% rename from app/Mails/Addresses.php rename to app/Domain/Mail/Addresses.php index e1c7d7b46..a5e921f56 100644 --- a/app/Mails/Addresses.php +++ b/app/Domain/Mail/Addresses.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Mails; +namespace App\Domain\Mail; use Illuminate\Support\Collection; use Symfony\Component\Mime\Address; diff --git a/app/Domain/Mail/Mailer.php b/app/Domain/Mail/Mailer.php index e9419ee47..7540a339b 100644 --- a/app/Domain/Mail/Mailer.php +++ b/app/Domain/Mail/Mailer.php @@ -4,7 +4,6 @@ namespace App\Domain\Mail; -use App\Mails\Addresses; use Symfony\Component\Mime\Address; interface Mailer diff --git a/app/Mails/MailManager.php b/app/MailJet/MailManager.php similarity index 98% rename from app/Mails/MailManager.php rename to app/MailJet/MailManager.php index c65ae9883..9b300c63d 100644 --- a/app/Mails/MailManager.php +++ b/app/MailJet/MailManager.php @@ -2,12 +2,13 @@ declare(strict_types=1); -namespace App\Mails; +namespace App\MailJet; use App\Domain\Contacts\Contact; use App\Domain\Integrations\Events\IntegrationActivated; use App\Domain\Integrations\Events\IntegrationBlocked; use App\Domain\Integrations\Repositories\IntegrationRepository; +use App\Domain\Mail\Addresses; use App\Domain\Mail\Mailer; use Symfony\Component\Mime\Address; diff --git a/app/Domain/Mail/MailjetConfig.php b/app/MailJet/MailjetConfig.php similarity index 95% rename from app/Domain/Mail/MailjetConfig.php rename to app/MailJet/MailjetConfig.php index 630240a1d..42fdc6a6c 100644 --- a/app/Domain/Mail/MailjetConfig.php +++ b/app/MailJet/MailjetConfig.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\Domain\Mail; +namespace App\MailJet; final class MailjetConfig { diff --git a/app/Domain/Mail/MailjetMailer.php b/app/MailJet/MailjetMailer.php similarity index 94% rename from app/Domain/Mail/MailjetMailer.php rename to app/MailJet/MailjetMailer.php index 40dc2aa13..74e0324ef 100644 --- a/app/Domain/Mail/MailjetMailer.php +++ b/app/MailJet/MailjetMailer.php @@ -2,9 +2,11 @@ declare(strict_types=1); -namespace App\Domain\Mail; +namespace App\MailJet; -use App\Mails\Addresses; +use App\Domain\Mail\Addresses; +use App\Domain\Mail\Mailer; +use App\Domain\Mail\MailNotSend; use Mailjet\Client; use Mailjet\Resources; use Psr\Log\LoggerInterface; diff --git a/app/Mails/MailServiceProvider.php b/app/MailJet/MailjetServiceProvider.php similarity index 91% rename from app/Mails/MailServiceProvider.php rename to app/MailJet/MailjetServiceProvider.php index aa5a26998..1e0f2ec7b 100644 --- a/app/Mails/MailServiceProvider.php +++ b/app/MailJet/MailjetServiceProvider.php @@ -2,20 +2,18 @@ declare(strict_types=1); -namespace App\Mails; +namespace App\MailJet; use App\Domain\Integrations\Events\IntegrationActivated; use App\Domain\Integrations\Events\IntegrationBlocked; use App\Domain\Integrations\Repositories\IntegrationRepository; use App\Domain\Mail\Mailer; -use App\Domain\Mail\MailjetConfig; -use App\Domain\Mail\MailjetMailer; use Illuminate\Support\Facades\Event; use Illuminate\Support\ServiceProvider; use Mailjet\Client; use Psr\Log\LoggerInterface; -final class MailServiceProvider extends ServiceProvider +final class MailjetServiceProvider extends ServiceProvider { public function register(): void { diff --git a/config/app.php b/config/app.php index 486ebde0f..7bfea16f8 100644 --- a/config/app.php +++ b/config/app.php @@ -204,7 +204,7 @@ App\ProjectAanvraag\ProjectAanvraagServiceProvider::class, App\Keycloak\KeycloakServiceProvider::class, App\Search\SearchServiceProvider::class, - App\Mails\MailServiceProvider::class, + \App\MailJet\MailjetServiceProvider::class, \App\Notifications\NotificationsProvider::class, ], diff --git a/tests/Mails/MailManagerTest.php b/tests/Mails/MailManagerTest.php index 9da349313..4280602cf 100644 --- a/tests/Mails/MailManagerTest.php +++ b/tests/Mails/MailManagerTest.php @@ -13,9 +13,9 @@ use App\Domain\Integrations\IntegrationStatus; use App\Domain\Integrations\IntegrationType; use App\Domain\Integrations\Repositories\IntegrationRepository; +use App\Domain\Mail\Addresses; use App\Domain\Mail\Mailer; -use App\Mails\Addresses; -use App\Mails\MailManager; +use App\MailJet\MailManager; use PHPUnit\Framework\MockObject\MockObject; use Ramsey\Uuid\Uuid; use Symfony\Component\Mime\Address; From 922b57da7d228f3ea98ca72edb46cb3a65d4ab46 Mon Sep 17 00:00:00 2001 From: Koen Eelen Date: Thu, 22 Aug 2024 11:09:25 +0200 Subject: [PATCH 2/2] feedback --- app/{MailJet => Domain/Mail}/MailManager.php | 5 +---- app/{ => Mails}/MailJet/MailjetConfig.php | 2 +- app/{ => Mails}/MailJet/MailjetMailer.php | 2 +- .../MailServiceProvider.php} | 9 ++++++--- config/app.php | 2 +- tests/{Mails => Domain/Mail}/MailManagerTest.php | 8 ++++---- 6 files changed, 14 insertions(+), 14 deletions(-) rename app/{MailJet => Domain/Mail}/MailManager.php (94%) rename app/{ => Mails}/MailJet/MailjetConfig.php (94%) rename app/{ => Mails}/MailJet/MailjetMailer.php (98%) rename app/{MailJet/MailjetServiceProvider.php => Mails/MailServiceProvider.php} (87%) rename tests/{Mails => Domain/Mail}/MailManagerTest.php (96%) diff --git a/app/MailJet/MailManager.php b/app/Domain/Mail/MailManager.php similarity index 94% rename from app/MailJet/MailManager.php rename to app/Domain/Mail/MailManager.php index 9b300c63d..77241ea23 100644 --- a/app/MailJet/MailManager.php +++ b/app/Domain/Mail/MailManager.php @@ -2,14 +2,12 @@ declare(strict_types=1); -namespace App\MailJet; +namespace App\Domain\Mail; use App\Domain\Contacts\Contact; use App\Domain\Integrations\Events\IntegrationActivated; use App\Domain\Integrations\Events\IntegrationBlocked; use App\Domain\Integrations\Repositories\IntegrationRepository; -use App\Domain\Mail\Addresses; -use App\Domain\Mail\Mailer; use Symfony\Component\Mime\Address; final class MailManager @@ -41,7 +39,6 @@ public function sendIntegrationActivatedMail(IntegrationActivated $integrationAc 'lastName' => $contact->lastName, 'contactType' => $contact->type->value, 'integrationName' => $integration->name, - //@todo Should we add a language preference to contacts? 'url' => $this->baseUrl . '/nl/integraties/' . $integration->id, 'type' => $integration->type->value, ] diff --git a/app/MailJet/MailjetConfig.php b/app/Mails/MailJet/MailjetConfig.php similarity index 94% rename from app/MailJet/MailjetConfig.php rename to app/Mails/MailJet/MailjetConfig.php index 42fdc6a6c..de6a53d17 100644 --- a/app/MailJet/MailjetConfig.php +++ b/app/Mails/MailJet/MailjetConfig.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\MailJet; +namespace App\Mails\MailJet; final class MailjetConfig { diff --git a/app/MailJet/MailjetMailer.php b/app/Mails/MailJet/MailjetMailer.php similarity index 98% rename from app/MailJet/MailjetMailer.php rename to app/Mails/MailJet/MailjetMailer.php index 74e0324ef..76f94f0cb 100644 --- a/app/MailJet/MailjetMailer.php +++ b/app/Mails/MailJet/MailjetMailer.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace App\MailJet; +namespace App\Mails\MailJet; use App\Domain\Mail\Addresses; use App\Domain\Mail\Mailer; diff --git a/app/MailJet/MailjetServiceProvider.php b/app/Mails/MailServiceProvider.php similarity index 87% rename from app/MailJet/MailjetServiceProvider.php rename to app/Mails/MailServiceProvider.php index 1e0f2ec7b..21df07910 100644 --- a/app/MailJet/MailjetServiceProvider.php +++ b/app/Mails/MailServiceProvider.php @@ -2,18 +2,21 @@ declare(strict_types=1); -namespace App\MailJet; +namespace App\Mails; use App\Domain\Integrations\Events\IntegrationActivated; use App\Domain\Integrations\Events\IntegrationBlocked; use App\Domain\Integrations\Repositories\IntegrationRepository; use App\Domain\Mail\Mailer; +use App\Domain\Mail\MailManager; +use App\Mails\MailJet\MailjetConfig; +use App\Mails\MailJet\MailjetMailer; use Illuminate\Support\Facades\Event; use Illuminate\Support\ServiceProvider; use Mailjet\Client; use Psr\Log\LoggerInterface; -final class MailjetServiceProvider extends ServiceProvider +final class MailServiceProvider extends ServiceProvider { public function register(): void { @@ -40,7 +43,7 @@ public function register(): void $this->app->get(IntegrationRepository::class), (int)config(MailjetConfig::TEMPLATE_INTEGRATION_ACTIVATED), (int)config(MailjetConfig::TEMPLATE_INTEGRATION_BLOCKED), - env('APP_URL') + config('url') ); }); diff --git a/config/app.php b/config/app.php index 7bfea16f8..fc97ae5c5 100644 --- a/config/app.php +++ b/config/app.php @@ -204,7 +204,7 @@ App\ProjectAanvraag\ProjectAanvraagServiceProvider::class, App\Keycloak\KeycloakServiceProvider::class, App\Search\SearchServiceProvider::class, - \App\MailJet\MailjetServiceProvider::class, + \App\Mails\MailServiceProvider::class, \App\Notifications\NotificationsProvider::class, ], diff --git a/tests/Mails/MailManagerTest.php b/tests/Domain/Mail/MailManagerTest.php similarity index 96% rename from tests/Mails/MailManagerTest.php rename to tests/Domain/Mail/MailManagerTest.php index 4280602cf..61650b680 100644 --- a/tests/Mails/MailManagerTest.php +++ b/tests/Domain/Mail/MailManagerTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Tests\Mails; +namespace Domain\Mail; use App\Domain\Contacts\Contact; use App\Domain\Contacts\ContactType; @@ -15,7 +15,7 @@ use App\Domain\Integrations\Repositories\IntegrationRepository; use App\Domain\Mail\Addresses; use App\Domain\Mail\Mailer; -use App\MailJet\MailManager; +use App\Domain\Mail\MailManager; use PHPUnit\Framework\MockObject\MockObject; use Ramsey\Uuid\Uuid; use Symfony\Component\Mime\Address; @@ -44,7 +44,7 @@ protected function setUp(): void $integrationRepository, self::TEMPLATE_ACTIVATED_ID, self::TEMPLATE_BLOCKED_ID, - 'http://www.example.com/' + 'http://www.example.com' ); // @todo Let add all types of contacts here, it might be the case that we only sent the email to specific type of contacts @@ -151,7 +151,7 @@ public static function mailDataProvider(): array 'templateId' => self::TEMPLATE_ACTIVATED_ID, 'subject' => 'Publiq platform - Integration activated', 'expectedParameters' => [ - 'url' => 'http://www.example.com//nl/integraties/' . self::INTEGRATION_ID, + 'url' => 'http://www.example.com/nl/integraties/' . self::INTEGRATION_ID, 'integrationName' => 'Mock Integration', 'type' => 'search-api', ],