From c5e1f86711380c42743629aacc0da0c09baa49bc Mon Sep 17 00:00:00 2001 From: mattamon Date: Mon, 22 Apr 2024 07:07:09 +0000 Subject: [PATCH] Apply php-cs-fixer changes --- src/EventSubscriber/ApiExceptionSubscriber.php | 6 ++---- src/Exception/ApiExceptionInterface.php | 2 +- src/Exception/InvalidFilterTypeException.php | 1 - src/Exception/InvalidQueryTypeException.php | 1 - src/Exception/InvalidSearchException.php | 1 - src/Service/SecurityService.php | 1 + 6 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/EventSubscriber/ApiExceptionSubscriber.php b/src/EventSubscriber/ApiExceptionSubscriber.php index 05dff0f0f..599960222 100644 --- a/src/EventSubscriber/ApiExceptionSubscriber.php +++ b/src/EventSubscriber/ApiExceptionSubscriber.php @@ -27,11 +27,10 @@ */ final class ApiExceptionSubscriber implements EventSubscriberInterface { - public static function getSubscribedEvents(): array { return [ - 'kernel.exception' => 'onKernelException' + 'kernel.exception' => 'onKernelException', ]; } @@ -40,7 +39,6 @@ public function onKernelException(ExceptionEvent $event): void $exception = $event->getThrowable(); $request = $event->getRequest(); - if(!$exception instanceof ApiExceptionInterface && !$this->isStudioApiCall($request->getPathInfo())) { return; } @@ -59,4 +57,4 @@ private function isStudioApiCall(string $path): bool { return str_starts_with($path, AbstractApiController::API_PATH); } -} \ No newline at end of file +} diff --git a/src/Exception/ApiExceptionInterface.php b/src/Exception/ApiExceptionInterface.php index 65be69a48..49c23d4d2 100644 --- a/src/Exception/ApiExceptionInterface.php +++ b/src/Exception/ApiExceptionInterface.php @@ -24,4 +24,4 @@ interface ApiExceptionInterface public function getStatusCode(): int; public function getMessage(): string; -} \ No newline at end of file +} diff --git a/src/Exception/InvalidFilterTypeException.php b/src/Exception/InvalidFilterTypeException.php index e9ebb2efb..786db2266 100644 --- a/src/Exception/InvalidFilterTypeException.php +++ b/src/Exception/InvalidFilterTypeException.php @@ -16,7 +16,6 @@ namespace Pimcore\Bundle\StudioApiBundle\Exception; - use Symfony\Component\HttpKernel\Exception\HttpException; /** diff --git a/src/Exception/InvalidQueryTypeException.php b/src/Exception/InvalidQueryTypeException.php index b262118e9..7b2c2e712 100644 --- a/src/Exception/InvalidQueryTypeException.php +++ b/src/Exception/InvalidQueryTypeException.php @@ -16,7 +16,6 @@ namespace Pimcore\Bundle\StudioApiBundle\Exception; -use Exception; use Symfony\Component\HttpKernel\Exception\HttpException; /** diff --git a/src/Exception/InvalidSearchException.php b/src/Exception/InvalidSearchException.php index a9f68fda8..526ed46b9 100644 --- a/src/Exception/InvalidSearchException.php +++ b/src/Exception/InvalidSearchException.php @@ -16,7 +16,6 @@ namespace Pimcore\Bundle\StudioApiBundle\Exception; -use Exception; use Symfony\Component\HttpKernel\Exception\HttpException; final class InvalidSearchException extends HttpException implements ApiExceptionInterface diff --git a/src/Service/SecurityService.php b/src/Service/SecurityService.php index 197995199..2eb4115a1 100644 --- a/src/Service/SecurityService.php +++ b/src/Service/SecurityService.php @@ -30,6 +30,7 @@ final readonly class SecurityService implements SecurityServiceInterface { private const STATUS_CODE = 401; + private const MESSAGE = 'Bad credentials'; public function __construct(