UrlHelper class for generating URLs.
Cake\View\ViewThe View instance this helper is attached to
stringAsset URL engine class name
array<string, mixed>Runtime config
boolWhether the config property has already been configured with defaults
array<string, mixed>Default config for this class
array<string, array>A helper lookup table used to lazy load helper objects.
arrayList of helpers used by this helper
Provide non fatal errors on missing method calls.
Default Constructor
Returns an array that can be used to describe the internal state of this object.
Lazy loads helpers.
Deletes a single config key.
Reads a config key.
Writes a config key.
Returns a string to be used as onclick handler for confirm dialogs.
Adds the given class to the element options
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 asset file.
Returns a URL based on provided parameters.
Returns a URL from a route path string.
Merge provided config with existing config. Unlike config() which does a recursive merge for nested keys, this method does a simple merge.
Generates URL for given CSS file.
Returns the config.
Returns the config for this specific key.
Get the view instance this helper is bound to.
Generates URL for given image file.
Event listeners.
Check proper configuration
Generates URL for given javascript file.
Sets the config.
Checks if a file exists when theme is used, if no file is found default location is returned
__call(string $method, array $params): mixed|void
Provide non fatal errors on missing method calls.
string $method Method to invoke
array $params Array of params for the method.
mixed|void__construct(Cake\View\View $view, array<string, mixed> $config = [])
Default Constructor
Cake\View\View $view The View this helper is being attached to.
array<string, mixed> $config optional Configuration settings for the helper.
__debugInfo(): array<string, mixed>
Returns an array that can be used to describe the internal state of this object.
array<string, mixed>__get(string $name): Cake\View\Helper|null|void
Lazy loads helpers.
string $name Name of the property being accessed.
Cake\View\Helper|null|void_configDelete(string $key): void
Deletes a single config key.
string $key Key to delete.
voidCake\Core\Exception\CakeException_configRead(string|null $key): mixed
Reads a config key.
string|null $key Key to read.
mixed_configWrite(array<string, mixed>|string $key, mixed $value, string|bool $merge = false): void
Writes a config key.
array<string, mixed>|string $key Key to write to.
mixed $value Value to write.
string|bool $merge optional True to merge recursively, 'shallow' for simple merge, false to overwrite, defaults to false.
voidCake\Core\Exception\CakeException_confirm(string $okCode, string $cancelCode): string
Returns a string to be used as onclick handler for confirm dialogs.
string $okCode Code to be executed after user chose 'OK'
string $cancelCode Code to be executed after user chose 'Cancel'
stringaddClass(array<string, mixed> $options, string $class, string $key = 'class'): array<string, mixed>
Adds the given class to the element options
array<string, mixed> $options Array options/attributes to add a class to
string $class The class name being added.
string $key optional the key to use for class. Defaults to 'class'.
array<string, mixed>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.
stringassetUrl(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 Helper::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 plugintimestamp 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.
stringbuild(array|string|null $url = null, array<string, mixed> $options = []): string
Returns a URL based on provided parameters.
escape: If false, the URL will be returned unescaped, do only use if it is manually escaped afterwards before being displayed.fullBase: If true, the full base URL will be prepended to the resultarray|string|null $url optional Either a relative string URL like /products/view/23 or an array of URL parameters. Using an array for URLs will allow you to leverage the reverse routing features of CakePHP.
array<string, mixed> $options optional Array of options.
stringbuildFromPath(string $path, array $params = [], array<string, mixed> $options = []): string
Returns a URL from a route path string.
escape: If false, the URL will be returned unescaped, do only use if it is manually escaped afterwards before being displayed.fullBase: If true, the full base URL will be prepended to the resultstring $path Cake-relative route path.
array $params optional An array specifying any additional parameters. Can be also any special parameters supported by Router::url().
array<string, mixed> $options optional Array of options.
stringconfigShallow(array<string, mixed>|string $key, mixed|null $value = null): $this
Merge provided config with existing config. Unlike config() which does a recursive merge for nested keys, this method does a simple merge.
Setting a specific value:
$this->configShallow('key', $value); Setting a nested value:
$this->configShallow('some.nested.key', $value); Updating multiple config settings at the same time:
$this->configShallow(['one' => 'value', 'another' => 'value']);
array<string, mixed>|string $key The key to set, or a complete array of configs.
mixed|null $value optional The value to set.
$thiscss(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 Helper::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.
stringgetConfig(string|null $key = null, mixed $default = null): mixed
Returns the config.
Reading the whole config:
$this->getConfig();
Reading a specific value:
$this->getConfig('key'); Reading a nested value:
$this->getConfig('some.nested.key'); Reading with default value:
$this->getConfig('some-key', 'default-value'); string|null $key optional The key to get or null for the whole config.
mixed $default optional The return value when the key does not exist.
mixedgetConfigOrFail(string $key): mixed
Returns the config for this specific key.
The config value for this key must exist, it can never be null.
string $key The key to get.
mixedInvalidArgumentExceptiongetView(): Cake\View\View
Get the view instance this helper is bound to.
Cake\View\Viewimage(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 Helper::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.
stringimplementedEvents(): array<string, mixed>
Event listeners.
By defining one of the callback methods a helper is assumed to be interested in the related event.
Override this method if you need to add non-conventional event listeners. Or if you want helpers to listen to non-standard events.
array<string, mixed>initialize(array<string, mixed> $config): void
Check proper configuration
Implement this method to avoid having to overwrite the constructor and call parent.
array<string, mixed> $config The configuration settings provided to this helper.
voidscript(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 Helper::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.
stringsetConfig(array<string, mixed>|string $key, mixed|null $value = null, bool $merge = true): $this
Sets the config.
Setting a specific value:
$this->setConfig('key', $value); Setting a nested value:
$this->setConfig('some.nested.key', $value); Updating multiple config settings at the same time:
$this->setConfig(['one' => 'value', 'another' => 'value']);
array<string, mixed>|string $key The key to set, or a complete array of configs.
mixed|null $value optional The value to set.
bool $merge optional Whether to recursively merge or overwrite existing config, defaults to true.
$thisCake\Core\Exception\CakeExceptionwebroot(string $file): string
Checks if a file exists when theme is used, if no file is found default location is returned
string $file The file to create a webroot path to.
stringThe View instance this helper is attached to
Cake\View\ViewAsset URL engine class name
stringRuntime config
array<string, mixed>Whether the config property has already been configured with defaults
boolDefault config for this class
array<string, mixed>A helper lookup table used to lazy load helper objects.
array<string, array>List of helpers used by this helper
array
© 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.View.Helper.UrlHelper.html