Skip to content

CacheableBinaryFileResponse

A file response that can be cached.

See https://www.drupal.org/project/drupal/issues/3227041.


  • Full name: \Drupal\helper\Response\CacheableBinaryFileResponse
  • Parent class: BinaryFileResponse
  • This class implements: CacheableResponseInterface

Properties

uri

The URI of the file.

protected string $uri

Methods

fromBinaryFileResponse

Construct a cacheable file response from an uncacheable one.

public static fromBinaryFileResponse(\Symfony\Component\HttpFoundation\BinaryFileResponse $response): static

The file, status code and headers are copied. The Cache-Control header is only copied when it was customized, so that Drupal's FinishResponseSubscriber can add its own. Symfony's defaults aren't treated as customized: the value it computes when the header isn't set, and the bare "public" that BinaryFileResponse sets by default, which has no max-age.

  • This method is static. Parameters:
Parameter Type Description
$response \Symfony\Component\HttpFoundation\BinaryFileResponse
The response to cache.

__serialize

Gets a serializable representation.

public __serialize(): array

Return Value:

Data for serialization.


__wakeup

Initializes uncacheable properties on unserialize.

public __wakeup(): void