Files
michaelschiemer/src/Application/Newsletter/SignUp/NewsletterSignup.php
Michael Schiemer 55a330b223 Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
2025-08-11 20:13:26 +02:00

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: '/'
);
}
}