mirror of
https://github.com/getgrav/grav.git
synced 2026-06-26 07:31:11 +02:00
Added has_env() twig function to test if environmental variable is defined
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
1. [](#new)
|
||||
* Added `FileInterface::touch()` method
|
||||
* Added optional `$field` parameter to `FlexMediaTrait::deleteMediaFile()` method
|
||||
* Added `has_env()` twig function to test if environmental variable is defined
|
||||
2. [](#improved)
|
||||
* By default, add media to only pages which have been initialized in pages loop
|
||||
3. [](#bugfix)
|
||||
|
||||
@@ -222,6 +222,7 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
|
||||
new TwigFunction('svg_image', [$this, 'svgImageFunction']),
|
||||
new TwigFunction('xss', [$this, 'xssFunc']),
|
||||
new TwigFunction('unique_id', [$this, 'uniqueId']),
|
||||
new TwigFunction('has_env', [$this, 'hasEnv']),
|
||||
|
||||
// Translations
|
||||
new TwigFunction('t', [$this, 'translate'], ['needs_environment' => true]),
|
||||
@@ -707,6 +708,15 @@ class GravExtension extends AbstractExtension implements GlobalsInterface
|
||||
return Utils::uniqueId($length, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $string
|
||||
* @return bool
|
||||
*/
|
||||
public function hasEnv($string): bool
|
||||
{
|
||||
return is_string($string) && getenv($string) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $string
|
||||
* @return string
|
||||
|
||||
Reference in New Issue
Block a user