function Request::getFormat
Gets the format associated with the mime type.
2 calls to Request::getFormat()
- Request::getContentTypeFormat in vendor/
symfony/ http-foundation/ Request.php - Gets the usual name of the format associated with the request's media type (provided in the Content-Type header).
- Request::getPreferredFormat in vendor/
symfony/ http-foundation/ Request.php - Gets the preferred format for the response by inspecting, in the following order:
File
-
vendor/
symfony/ http-foundation/ Request.php, line 1228
Class
- Request
- Request represents an HTTP request.
Namespace
Symfony\Component\HttpFoundationCode
public function getFormat(?string $mimeType) : ?string {
$canonicalMimeType = null;
if ($mimeType && false !== ($pos = strpos($mimeType, ';'))) {
$canonicalMimeType = trim(substr($mimeType, 0, $pos));
}
if (null === static::$formats) {
static::initializeFormats();
}
foreach (static::$formats as $format => $mimeTypes) {
if (\in_array($mimeType, (array) $mimeTypes, true)) {
return $format;
}
if (null !== $canonicalMimeType && \in_array($canonicalMimeType, (array) $mimeTypes, true)) {
return $format;
}
}
return null;
}