diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a442f0f7..981a6e551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ * Added `PermissionsRegisterEvent` which triggers when `$grav['permissions']` is being accessed the first time 1. [](#improved) * Blueprint validation: Added `validate: value_type: bool|int|float|string|trim` to `array` to filter all the values inside the array + * Twig `url()` takes now third parameter (`true`) to return URL on non-existing file instead of returning false 1. [](#bugfix) * Grav 1.7: Fixed blueprint loading issues [#2782](https://github.com/getgrav/grav/issues/2782) * Fixed PHP 7.4 compatibility issue with `Stream` diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index 6ac2b9133..e0fc19084 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -848,12 +848,12 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface * * @param string $input Resource to be located. * @param bool $domain True to include domain name. - * - * @return string|null Returns url to the resource or null if resource was not found. + * @param bool $failGracefully If true, return URL even if the file does not exist. + * @return string|false Returns url to the resource or null if resource was not found. */ - public function urlFunc($input, $domain = false) + public function urlFunc($input, $domain = false, $failGracefully = false) { - return Utils::url($input, $domain); + return Utils::url($input, $domain, $failGracefully); } /** diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 355e9b63a..6ea79a2ab 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -34,7 +34,7 @@ abstract class Utils * @param string|object $input * @param bool $domain * @param bool $fail_gracefully - * @return bool|null|string + * @return string|false */ public static function url($input, $domain = false, $fail_gracefully = false) {