From fe988504d4fb2f9f1fd3c575fee497916bbf7a94 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 9 Jun 2018 20:52:17 +0700 Subject: [PATCH] rename function name for detect content type --- src/HeroFunction.php | 2 +- src/Listener/Mvc.php | 4 ++-- src/Middleware/Expressive.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) 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);