Skip to content

Commit

Permalink
fix(response) Remove JsonStandard response type
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAnyx committed Dec 4, 2024
1 parent c91cdb3 commit d0c2a0c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 108 deletions.
21 changes: 7 additions & 14 deletions config/packages/nelmio_cors.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
nelmio_cors:
defaults:
allow_origin: ["*"]
allow_credentials: true
origin_regex: false
allow_origin: ["%env(CORS_ALLOW_ORIGIN)%"]
allow_methods: ["GET", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"]
allow_headers: ["Content-Type", "Authorization", "Accept"]
expose_headers: ["Link"]
max_age: 3600
paths:
"^/": null

when@prod:
nelmio_cors:
defaults:
allow_credentials: true
origin_regex: false
allow_origin: ["%env(CORS_ALLOW_ORIGIN)%"]
allow_methods: ["GET", "OPTIONS", "POST", "PUT", "PATCH", "DELETE"]
allow_headers: ["Content-Type", "Authorization", "Accept"]
expose_headers: ["Link"]
max_age: 3600
paths:
"^/": null
2 changes: 2 additions & 0 deletions src/Controller/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class TestController extends AbstractRestController
#[Route('/test', name: 'test')]
public function index(Request $request): JsonResponse
{
throw new \Exception('Test');

return $this->json(null);
}
}
14 changes: 0 additions & 14 deletions src/Enum/ContentType.php

This file was deleted.

7 changes: 4 additions & 3 deletions src/EventSubscriber/ExceptionSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
Expand All @@ -30,11 +31,11 @@ public function onKernelException(ExceptionEvent $event): void
$exception = $event->getThrowable();
$statusCode = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR;

$response = new Response(
json_encode([
$response = new JsonResponse(
[
'message' => Response::$statusTexts[$statusCode],
'details' => $exception->getMessage(),
]),
],
$statusCode
);

Expand Down
74 changes: 0 additions & 74 deletions src/EventSubscriber/ResponseSubscriber.php

This file was deleted.

2 changes: 0 additions & 2 deletions src/Factory/FlashcardFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

declare(strict_types=1);

declare(strict_types=1);

namespace App\Factory;

use App\Entity\Flashcard;
Expand Down
2 changes: 1 addition & 1 deletion src/MessageHandler/SendTextEmailMessageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(
public function __invoke(SendTextEmailMessage $message): void
{
$email = (new Email())
->from('noreply@example.com')
->from($this->sender)
->to($message->email)
->priority($message->priority)
->subject($message->subject)
Expand Down

0 comments on commit d0c2a0c

Please sign in to comment.