FileUrlGeneratorInterface
interface FileUrlGeneratorInterface (View source)
Generates file URLs for a stream to an external or local file.
Compatibility: normal paths and stream wrappers.
There are two kinds of local files:
- "managed files", i.e. those stored by a Drupal-compatible stream wrapper. These are files that have either been uploaded by users or were generated automatically (for example through CSS aggregation).
- "shipped files", i.e. those outside of the files directory, which ship as part of Drupal core or contributed modules or themes.
Separate methods are provided to provide absolute and relative URLs as well as plain strings or Url objects, depending on the requirements. In general, it is recommended to always use relative URLs unless absolute URL's are required.
Methods
Creates a root-relative web-accessible URL string.
Creates an absolute web-accessible URL string.
Transforms an absolute URL of a local file to a relative URL.
Details
string
generateString(string $uri)
Creates a root-relative web-accessible URL string.
string
generateAbsoluteString(string $uri)
Creates an absolute web-accessible URL string.
Url
generate(string $uri)
Creates a root-relative web-accessible URL object.
string
transformRelative(string $file_url, bool $root_relative = TRUE)
Transforms an absolute URL of a local file to a relative URL.
May be useful to prevent problems on multisite set-ups and prevent mixed content errors when using HTTPS + HTTP.