Class for generating asset URLs.
stringInflection type.
Adds a timestamp to a file based resource based on the value of Asset.timestamp in Configure. If Asset.timestamp is true and debug is true, or Asset.timestamp === 'force' a timestamp will be added.
Generates URL for given CSS file.
Encodes URL parts using rawurlencode().
Generates URL for given image file.
Inflect the theme/plugin name to type set using Asset::setInflectionType().
Splits a dot syntax plugin name into its plugin and filename. If $name does not have a dot, then index 0 will be null. It checks if the plugin is loaded, else filename will stay unchanged for filenames containing dot.
Get webroot from request.
Generates URL for given javascript file.
Set inflection type to use when inflecting plugin/theme name.
Generates URL for given asset file.
Checks if a file exists when theme is used, if no file is found default location is returned.
assetTimestamp(string $path, string|bool $timestamp = null): string
Adds a timestamp to a file based resource based on the value of Asset.timestamp in Configure. If Asset.timestamp is true and debug is true, or Asset.timestamp === 'force' a timestamp will be added.
string $path The file path to timestamp, the path must be inside App.wwwRoot in Configure.
string|bool $timestamp optional If set will overrule the value of Asset.timestamp in Configure.
stringcssUrl(string $path, array<string, mixed> $options = []): string
Generates URL for given CSS file.
Depending on options passed provides full URL with domain name. Also calls Asset::assetTimestamp() to add timestamp to local files.
string $path Path string.
array<string, mixed> $options optional Options array. Possible keys: fullBase Return full URL with domain name pathPrefix Path prefix for relative URLs ext Asset extension to append plugin False value will prevent parsing path as a plugin timestamp Overrides the value of Asset.timestamp in Configure. Set to false to skip timestamp generation. Set to true to apply timestamps when debug is true. Set to 'force' to always enable timestamping regardless of debug value.
stringencodeUrl(string $url): string
Encodes URL parts using rawurlencode().
string $url The URL to encode.
stringimageUrl(string $path, array<string, mixed> $options = []): string
Generates URL for given image file.
Depending on options passed provides full URL with domain name. Also calls Asset::assetTimestamp() to add timestamp to local files.
string $path Path string.
array<string, mixed> $options optional Options array. Possible keys: fullBase Return full URL with domain name pathPrefix Path prefix for relative URLs plugin False value will prevent parsing path as a plugin timestamp Overrides the value of Asset.timestamp in Configure. Set to false to skip timestamp generation. Set to true to apply timestamps when debug is true. Set to 'force' to always enable timestamping regardless of debug value.
stringinflectString(string $string): string
Inflect the theme/plugin name to type set using Asset::setInflectionType().
string $string String inflected.
stringpluginSplit(string $name): array
Splits a dot syntax plugin name into its plugin and filename. If $name does not have a dot, then index 0 will be null. It checks if the plugin is loaded, else filename will stay unchanged for filenames containing dot.
string $name The name you want to plugin split.
arrayrequestWebroot(): string
Get webroot from request.
stringscriptUrl(string $path, array<string, mixed> $options = []): string
Generates URL for given javascript file.
Depending on options passed provides full URL with domain name. Also calls Asset::assetTimestamp() to add timestamp to local files.
string $path Path string.
array<string, mixed> $options optional Options array. Possible keys: fullBase Return full URL with domain name pathPrefix Path prefix for relative URLs ext Asset extension to append plugin False value will prevent parsing path as a plugin timestamp Overrides the value of Asset.timestamp in Configure. Set to false to skip timestamp generation. Set to true to apply timestamps when debug is true. Set to 'force' to always enable timestamping regardless of debug value.
stringsetInflectionType(string $inflectionType): void
Set inflection type to use when inflecting plugin/theme name.
string $inflectionType Inflection type. Value should be a valid method name of Inflector class like 'dasherize' or 'underscore'`.
voidurl(string $path, array<string, mixed> $options = []): string
Generates URL for given asset file.
Depending on options passed provides full URL with domain name. Also calls Asset::assetTimestamp() to add timestamp to local files.
fullBase Boolean true or a string (e.g. https://example) to return full URL with protocol and domain name.pathPrefix Path prefix for relative URLsext Asset extension to appendplugin False value will prevent parsing path as a plugintheme Optional theme nametimestamp Overrides the value of Asset.timestamp in Configure. Set to false to skip timestamp generation. Set to true to apply timestamps when debug is true. Set to 'force' to always enable timestamping regardless of debug value.string $path Path string or URL array
array<string, mixed> $options optional Options array.
stringwebroot(string $file, array<string, mixed> $options = []): string
Checks if a file exists when theme is used, if no file is found default location is returned.
theme Optional theme namestring $file The file to create a webroot path to.
array<string, mixed> $options optional Options array.
stringInflection type.
string
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Routing.Asset.html