Fixed missing and commonly used methods when using system.twig.undefined_functions = false

This commit is contained in:
Matias Griese
2021-05-10 12:27:11 +03:00
parent d058c1d4fc
commit 7d01977a89
3 changed files with 31 additions and 3 deletions

View File

@@ -8,6 +8,7 @@
* Fixed fatal error with some markdown links [getgrav/grav-premium-issues#95](https://github.com/getgrav/grav-premium-issues/issues/95)
* Fixed markdown media operations not working when using `image://` stream [#3333](https://github.com/getgrav/grav/issues/3333) [#3349](https://github.com/getgrav/grav/issues/3349)
* Fixed copying page without changing the slug [getgrav/grav-plugin-admin#2135](https://github.com/getgrav/grav-plugin-admin/issues/2139)
* Fixed missing and commonly used methods when using `system.twig.undefined_functions = false` [getgrav/grav-plugin-admin#2138](https://github.com/getgrav/grav-plugin-admin/issues/2138)
# v1.7.14
## 04/29/2021

View File

@@ -31,7 +31,7 @@ class FilesystemExtension extends AbstractExtension
}
/**
* @return TwigFunction[]
* @return TwigFilter[]
*/
public function getFilters()
{
@@ -58,6 +58,7 @@ class FilesystemExtension extends AbstractExtension
new TwigFilter('md5_file', [$this, 'md5_file']),
new TwigFilter('sha1_file', [$this, 'sha1_file']),
new TwigFilter('get_meta_tags', [$this, 'get_meta_tags']),
new TwigFilter('pathinfo', [$this, 'pathinfo']),
];
}
@@ -91,6 +92,7 @@ class FilesystemExtension extends AbstractExtension
new TwigFunction('md5_file', [$this, 'md5_file']),
new TwigFunction('sha1_file', [$this, 'sha1_file']),
new TwigFunction('get_meta_tags', [$this, 'get_meta_tags']),
new TwigFunction('pathinfo', [$this, 'pathinfo']),
];
}
@@ -364,6 +366,16 @@ class FilesystemExtension extends AbstractExtension
return get_meta_tags($filename);
}
/**
* @param string $path
* @param int $flags
* @return string|string[]
*/
public function pathinfo($path, $flags = PATHINFO_ALL)
{
return pathinfo($path);
}
/**
* @param string $filename
* @return bool

View File

@@ -158,7 +158,11 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
// Object Types
new TwigFilter('get_type', [$this, 'getTypeFunc']),
new TwigFilter('of_type', [$this, 'ofTypeFunc'])
new TwigFilter('of_type', [$this, 'ofTypeFunc']),
// PHP methods
new TwigFilter('count', 'count'),
new TwigFilter('array_diff', 'array_diff'),
];
}
@@ -220,7 +224,18 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
// Object Types
new TwigFunction('get_type', [$this, 'getTypeFunc']),
new TwigFunction('of_type', [$this, 'ofTypeFunc'])
new TwigFunction('of_type', [$this, 'ofTypeFunc']),
// PHP methods
new TwigFunction('is_numeric', 'is_numeric'),
new TwigFunction('is_iterable', 'is_iterable'),
new TwigFunction('is_countable', 'is_countable'),
new TwigFunction('is_null', 'is_null'),
new TwigFunction('is_string', 'is_string'),
new TwigFunction('is_array', 'is_array'),
new TwigFunction('is_object', 'is_object'),
new TwigFunction('count', 'count'),
new TwigFunction('array_diff', 'array_diff'),
];
}