From 92b7dd3335a6572debeacfb5faa82c63a5e67888 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 8 Jun 2018 20:03:25 +0200 Subject: Some minor fixes --- .../src/Http/Concerns/DeterminesContentType.php | 152 ++++++++++----------- 1 file changed, 76 insertions(+), 76 deletions(-) (limited to 'main/app/sprinkles/core/src/Http') diff --git a/main/app/sprinkles/core/src/Http/Concerns/DeterminesContentType.php b/main/app/sprinkles/core/src/Http/Concerns/DeterminesContentType.php index 06cf0b3..2a22331 100644 --- a/main/app/sprinkles/core/src/Http/Concerns/DeterminesContentType.php +++ b/main/app/sprinkles/core/src/Http/Concerns/DeterminesContentType.php @@ -1,76 +1,76 @@ -isXhr()) { - return 'text/html'; - } - - $acceptHeader = $request->getHeaderLine('Accept'); - $selectedContentTypes = array_intersect(explode(',', $acceptHeader), $this->knownContentTypes); - $count = count($selectedContentTypes); - - if ($count) { - $current = current($selectedContentTypes); - - /** - * Ensure other supported content types take precedence over text/plain - * when multiple content types are provided via Accept header. - */ - if ($current === 'text/plain' && $count > 1) { - return next($selectedContentTypes); - } - - return $current; - } - - if (preg_match('/\+(json|xml)/', $acceptHeader, $matches)) { - $mediaType = 'application/' . $matches[1]; - if (in_array($mediaType, $this->knownContentTypes)) { - return $mediaType; - } - } - - return 'text/html'; - } -} +isXhr()) { + return 'text/html'; + } + + $acceptHeader = $request->getHeaderLine('Accept'); + $selectedContentTypes = array_intersect(explode(',', $acceptHeader), $this->knownContentTypes); + $count = count($selectedContentTypes); + + if ($count) { + $current = current($selectedContentTypes); + + /** + * Ensure other supported content types take precedence over text/plain + * when multiple content types are provided via Accept header. + */ + if ($current === 'text/plain' && $count > 1) { + return next($selectedContentTypes); + } + + return $current; + } + + if (preg_match('/\+(json|xml)/', $acceptHeader, $matches)) { + $mediaType = 'application/' . $matches[1]; + if (in_array($mediaType, $this->knownContentTypes)) { + return $mediaType; + } + } + + return 'text/html'; + } +} -- cgit v1.2.3