Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Request.php

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\HttpFoundation

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal