ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AbstractHandler.php
Go to the documentation of this file.
1 <?php
9 namespace Slim\Handlers;
10 
12 
16 abstract class AbstractHandler
17 {
23  protected $knownContentTypes = [
24  'application/json',
25  'application/xml',
26  'text/xml',
27  'text/html',
28  ];
29 
41  {
42  $acceptHeader = $request->getHeaderLine('Accept');
43  $selectedContentTypes = array_intersect(explode(',', $acceptHeader), $this->knownContentTypes);
44 
45  if (count($selectedContentTypes)) {
46  return current($selectedContentTypes);
47  }
48 
49  // handle +json and +xml specially
50  if (preg_match('/\+(json|xml)/', $acceptHeader, $matches)) {
51  $mediaType = 'application/' . $matches[1];
52  if (in_array($mediaType, $this->knownContentTypes)) {
53  return $mediaType;
54  }
55  }
56 
57  return 'text/html';
58  }
59 }
Representation of an incoming, server-side HTTP request.
foreach($paths as $path) $request
Definition: asyncclient.php:32
determineContentType(ServerRequestInterface $request)
Determine which content type we know about is wanted using Accept header.
Slim Framework (https://slimframework.com)
getHeaderLine($name)
Retrieves a comma-separated string of the values for a single header.
Abstract Slim application handler.