Initial commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\MessageHandler;
|
||||
|
||||
use Atournayre\Common\AbstractQueryEvent;
|
||||
use Atournayre\Contracts\CommandBus\QueryInterface;
|
||||
|
||||
final class UtilisateurUrlsMessage extends AbstractQueryEvent implements QueryInterface
|
||||
{
|
||||
private function __construct(
|
||||
public string $id,
|
||||
) {
|
||||
}
|
||||
|
||||
public static function new(
|
||||
string $id,
|
||||
): self {
|
||||
return new self(
|
||||
id: $id,
|
||||
);
|
||||
}
|
||||
|
||||
public function id(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\MessageHandler;
|
||||
|
||||
use App\Repository\UtilisateurRepositoryInterface;
|
||||
use App\Urls\UtilisateurUrls;
|
||||
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
#[AsMessageHandler]
|
||||
final readonly class UtilisateurUrlsMessageHandler
|
||||
{
|
||||
public function __construct(
|
||||
private UtilisateurRepositoryInterface $utilisateurRepository,
|
||||
private UrlGeneratorInterface $urlGenerator,
|
||||
) {
|
||||
}
|
||||
|
||||
public function __invoke(UtilisateurUrlsMessage $message): UtilisateurUrls
|
||||
{
|
||||
$utilisateur = $this->utilisateurRepository->find($message->id());
|
||||
|
||||
return UtilisateurUrls::new(
|
||||
urlGenerator: $this->urlGenerator,
|
||||
utilisateur: $utilisateur,
|
||||
);
|
||||
}
|
||||
}
|
||||
27
skills/make-urls/templates/Urls/UtilisateurUrls.php
Normal file
27
skills/make-urls/templates/Urls/UtilisateurUrls.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Urls;
|
||||
|
||||
use App\Entity\Utilisateur;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
final readonly class UtilisateurUrls
|
||||
{
|
||||
private function __construct(
|
||||
private UrlGeneratorInterface $urlGenerator,
|
||||
private Utilisateur $utilisateur,
|
||||
) {
|
||||
}
|
||||
|
||||
public static function new(
|
||||
UrlGeneratorInterface $urlGenerator,
|
||||
Utilisateur $utilisateur,
|
||||
): self {
|
||||
return new self(
|
||||
urlGenerator: $urlGenerator,
|
||||
utilisateur: $utilisateur,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user