diff --git a/src/HeroFunction.php b/src/HeroFunction.php index 3218d274..95055f77 100644 --- a/src/HeroFunction.php +++ b/src/HeroFunction.php @@ -6,7 +6,7 @@ use Seld\JsonLint\JsonParser; -function detectAjaxMessageContentType(string $message) : string +function detectMessageContentType(string $message) : string { return (new JsonParser())->lint($message) === null ? 'application/problem+json' diff --git a/src/Listener/Mvc.php b/src/Listener/Mvc.php index 3e16f9cc..66080f12 100644 --- a/src/Listener/Mvc.php +++ b/src/Listener/Mvc.php @@ -17,7 +17,7 @@ use Zend\Text\Table; use Zend\View\Renderer\PhpRenderer; -use function ErrorHeroModule\detectAjaxMessageContentType; +use function ErrorHeroModule\detectMessageContentType; class Mvc extends AbstractListenerAggregate { @@ -106,7 +106,7 @@ private function showDefaultViewWhenDisplayErrorSetttingIsDisabled(MvcEvent $e, ->detach($events); $message = $this->errorHeroModuleConfig['display-settings']['ajax']['message']; - $contentType = detectAjaxMessageContentType($message); + $contentType = detectMessageContentType($message); $response->getHeaders()->addHeaderLine('Content-type', $contentType); $response->setContent($message); diff --git a/src/Middleware/Expressive.php b/src/Middleware/Expressive.php index 0b1c29f0..f2a67597 100644 --- a/src/Middleware/Expressive.php +++ b/src/Middleware/Expressive.php @@ -21,7 +21,7 @@ use Zend\Psr7Bridge\Psr7ServerRequest; use Zend\View\Model\ViewModel; -use function ErrorHeroModule\detectAjaxMessageContentType; +use function ErrorHeroModule\detectMessageContentType; class Expressive implements MiddlewareInterface { @@ -90,7 +90,7 @@ public function exceptionError(Throwable $t, ServerRequestInterface $request) : private function responseByConfigMessage($key) : ResponseInterface { $message = $this->errorHeroModuleConfig['display-settings'][$key]['message']; - $contentType = detectAjaxMessageContentType($message); + $contentType = detectMessageContentType($message); $response = new Response(); $response->getBody()->write($message);