function FileUrlGeneratorInterface::generate

Same name in other branches
  1. 9 core/lib/Drupal/Core/File/FileUrlGeneratorInterface.php \Drupal\Core\File\FileUrlGeneratorInterface::generate()
  2. 11.x core/lib/Drupal/Core/File/FileUrlGeneratorInterface.php \Drupal\Core\File\FileUrlGeneratorInterface::generate()

Creates a root-relative web-accessible URL object.

Parameters

string $uri: The URI to a file for which we need an external URL, or the path to a shipped file.

Return value

\Drupal\Core\Url For a local URL (matching domain), a base-relative Url object containing a URL that may be used to access the file. An Url object with absolute URL may be returned when using a CDN or a remote stream wrapper. Use setAbsolute() on the Url object to build an absolute URL.

Throws

\Drupal\Core\File\Exception\InvalidStreamWrapperException If a stream wrapper could not be found to generate an external URL.

File

core/lib/Drupal/Core/File/FileUrlGeneratorInterface.php, line 75

Class

FileUrlGeneratorInterface
Generates file URLs for a stream to an external or local file.

Namespace

Drupal\Core\File

Code

public function generate(string $uri) : Url;

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.