- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Application\Newsletter\SignUp;
|
|
|
|
use App\Framework\Attributes\Route;
|
|
use App\Framework\CommandBus\CommandBus;
|
|
use App\Framework\Http\Method;
|
|
use App\Framework\Router\Result\ContentNegotiationResult;
|
|
|
|
final readonly class NewsletterSignup
|
|
{
|
|
public function __construct(
|
|
public CommandBus $commandBus,
|
|
) {
|
|
}
|
|
|
|
#[Route(path: '/newsletter/register', method: Method::POST)]
|
|
public function __invoke(NewsletterSignupRequest $request): ContentNegotiationResult
|
|
{
|
|
// Den internen Command ausführen
|
|
$command = new SignupUserToNewsletter($request->name, $request->email);
|
|
|
|
$result = $this->commandBus->dispatch($command);
|
|
|
|
|
|
// Hier könnten Sie das Ergebnis weiterverarbeiten oder loggen
|
|
return new ContentNegotiationResult(
|
|
jsonPayload: [
|
|
'success' => true,
|
|
'message' => 'Anmeldung erfolgreich!',
|
|
'data' => [
|
|
$request->name,
|
|
$request->email,
|
|
],
|
|
],
|
|
redirectTo: '/'
|
|
);
|
|
}
|
|
}
|