Twig url() takes now third parameter (true) to return URL on non-existing file instead of returning false

This commit is contained in:
Matias Griese
2020-01-21 22:35:02 +02:00
parent b4630aeb38
commit afac6baa11
3 changed files with 6 additions and 5 deletions

View File

@@ -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`

View File

@@ -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);
}
/**

View File

@@ -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)
{