From d0fd6676f30ecb8ce04662da84ec73b551bfec0d Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 11 Jul 2022 13:43:59 +0300 Subject: [PATCH] fix(expressions): fix `url` expressions --- .../core/Entries/Expressions/UrlExpression.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/flextype/core/Entries/Expressions/UrlExpression.php b/src/flextype/core/Entries/Expressions/UrlExpression.php index 4d066910..78a72cae 100644 --- a/src/flextype/core/Entries/Expressions/UrlExpression.php +++ b/src/flextype/core/Entries/Expressions/UrlExpression.php @@ -30,22 +30,24 @@ use function Flextype\getUriString; use function Flextype\isCurrentUrl; use function Flextype\redirect; use function Flextype\urlFor; +use function Flextype\url; class UrlExpression implements ExpressionFunctionProviderInterface { public function getFunctions() { return [ - new ExpressionFunction('urlFor', static fn (string $routeName, array $data = [], array $queryParams = []) => '\Flextype\urlFor($routeName, $data, $queryParams)', static fn (string $routeName, array $data = [], array $queryParams = []) => urlFor($routeName, $data, $queryParams)), - new ExpressionFunction('fullUrlFor', static fn (ServerRequestInterface $request, string $routeName, array $data = [], array $queryParams = []) => '\Flextype\fullUrlFor($request, $routeName, $data, $queryParams)', static fn (ServerRequestInterface $request, string $routeName, array $data = [], array $queryParams = []) => fullUrlFor($request, $routeName, $data = [], $queryParams = [])), - new ExpressionFunction('isCurrentUrl', static fn (ServerRequestInterface $request, string $routeName, array $data = []) => '\Flextype\isCurrentUrl($request, $routeName, $data)', static fn (ServerRequestInterface $request, string $routeName, array $data = []) => isCurrentUrl($request, $routeName, $data = [])), - new ExpressionFunction('getCurrentUrl', static fn (ServerRequestInterface $request, bool $withQueryString = false) => '\Flextype\getCurrentUrl($request, $withQueryString)', static fn (ServerRequestInterface $request, bool $withQueryString = false) => getCurrentUrl($request, $withQueryString)), + new ExpressionFunction('url', static fn (string $string = '', string $prefix = 'base') => '\Flextype\url($string, $prefix)', static fn ($arguments, string $string = '', string $prefix = 'base') => urlFor($string, $prefix)), + new ExpressionFunction('urlFor', static fn (string $routeName, array $data = [], array $queryParams = []) => '\Flextype\urlFor($routeName, $data, $queryParams)', static fn ($arguments, string $routeName, array $data = [], array $queryParams = []) => urlFor($routeName, $data, $queryParams)), + new ExpressionFunction('fullUrlFor', static fn (ServerRequestInterface $request, string $routeName, array $data = [], array $queryParams = []) => '\Flextype\fullUrlFor($request, $routeName, $data, $queryParams)', static fn ($arguments, ServerRequestInterface $request, string $routeName, array $data = [], array $queryParams = []) => fullUrlFor($request, $routeName, $data = [], $queryParams = [])), + new ExpressionFunction('isCurrentUrl', static fn (ServerRequestInterface $request, string $routeName, array $data = []) => '\Flextype\isCurrentUrl($request, $routeName, $data)', static fn ($arguments, ServerRequestInterface $request, string $routeName, array $data = []) => isCurrentUrl($request, $routeName, $data = [])), + new ExpressionFunction('getCurrentUrl', static fn (ServerRequestInterface $request, bool $withQueryString = false) => '\Flextype\getCurrentUrl($request, $withQueryString)', static fn ($arguments, ServerRequestInterface $request, bool $withQueryString = false) => getCurrentUrl($request, $withQueryString)), new ExpressionFunction('getBasePath', static fn () => '\Flextype\getBasePath()', static fn () => getBasePath()), new ExpressionFunction('getBaseUrl', static fn () => '\Flextype\getBaseUrl()', static fn () => getBaseUrl()), new ExpressionFunction('getAbsoluteUrl', static fn () => '\Flextype\getAbsoluteUrl()', static fn () => getAbsoluteUrl()), new ExpressionFunction('getProjectUrl', static fn () => '\Flextype\getProjectUrl()', static fn () => getProjectUrl()), new ExpressionFunction('getUriString', static fn () => '\Flextype\getUriString()', static fn () => getUriString()), - new ExpressionFunction('redirect', static fn (string $routeName, array $data = [], array $queryParams = [], int $status = 301) => '\Flextype\redirect($routeName, $data, $queryParams, $status)', static fn (string $routeName, array $data = [], array $queryParams = [], int $status = 301) => redirect($routeName, $data, $queryParams, $status)), + new ExpressionFunction('redirect', static fn (string $routeName, array $data = [], array $queryParams = [], int $status = 301) => '\Flextype\redirect($routeName, $data, $queryParams, $status)', static fn ($arguments, string $routeName, array $data = [], array $queryParams = [], int $status = 301) => redirect($routeName, $data, $queryParams, $status)), ]; } }