|
|
@@ -14,27 +14,51 @@ declare(strict_types=1);
|
|
|
* @since 4.1.0
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License
|
|
|
*/
|
|
|
+// phpcs:disable SlevomatCodingStandard.Namespaces.NamespaceDeclaration.DisallowedBracketedSyntax
|
|
|
+namespace {
|
|
|
|
|
|
-use Cake\Routing\Router;
|
|
|
+ use Cake\Routing\Router;
|
|
|
|
|
|
-if (!function_exists('urlArray')) {
|
|
|
+ if (!function_exists('urlArray')) {
|
|
|
+ /**
|
|
|
+ * Returns an array URL from a route path string.
|
|
|
+ *
|
|
|
+ * @param string $path Route path.
|
|
|
+ * @param array $params An array specifying any additional parameters.
|
|
|
+ * Can be also any special parameters supported by `Router::url()`.
|
|
|
+ * @return array URL
|
|
|
+ * @see \Cake\Routing\Router::pathUrl()
|
|
|
+ */
|
|
|
+ function urlArray(string $path, array $params = []): array
|
|
|
+ {
|
|
|
+ $url = Router::parseRoutePath($path);
|
|
|
+ $url += [
|
|
|
+ 'plugin' => false,
|
|
|
+ 'prefix' => false,
|
|
|
+ ];
|
|
|
+
|
|
|
+ return $url + $params;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+namespace Cake\Routing {
|
|
|
/**
|
|
|
- * Returns an array URL from a route path string.
|
|
|
+ * Convenience wrapper for Router::url().
|
|
|
*
|
|
|
- * @param string $path Route path.
|
|
|
- * @param array $params An array specifying any additional parameters.
|
|
|
- * Can be also any special parameters supported by `Router::url()`.
|
|
|
- * @return array URL
|
|
|
- * @see \Cake\Routing\Router::pathUrl()
|
|
|
+ * @param \Psr\Http\Message\UriInterface|array|string|null $url An array specifying any of the following:
|
|
|
+ * 'controller', 'action', 'plugin' additionally, you can provide routed
|
|
|
+ * elements or query string parameters. If string it can be name any valid url
|
|
|
+ * string or it can be an UriInterface instance.
|
|
|
+ * @param bool $full If true, the full base URL will be prepended to the result.
|
|
|
+ * Default is false.
|
|
|
+ * @return string Full translated URL with base path.
|
|
|
+ * @throws \Cake\Core\Exception\CakeException When the route name is not found
|
|
|
+ * @see \Cake\Routing\Router::url()
|
|
|
+ * @since 4.5.0
|
|
|
*/
|
|
|
- function urlArray(string $path, array $params = []): array
|
|
|
+ function url($url = null, bool $full = false): string
|
|
|
{
|
|
|
- $url = Router::parseRoutePath($path);
|
|
|
- $url += [
|
|
|
- 'plugin' => false,
|
|
|
- 'prefix' => false,
|
|
|
- ];
|
|
|
-
|
|
|
- return $url + $params;
|
|
|
+ return Router::url($url, $full);
|
|
|
}
|
|
|
}
|