mirror of
https://github.com/getgrav/grav.git
synced 2025-02-20 19:56:53 +01:00
Added array_key_exists wrapper function
This commit is contained in:
parent
a37582eb4c
commit
c7c234d04a
|
|
@ -6,6 +6,7 @@
|
|||
* Added a new `clear_images_by_default` system property to stop cache clear events from removing processed images [#1481](https://github.com/getgrav/grav/pull/1481)
|
||||
* Added new `onTwigLoader()` event to enable utilization of loader methods
|
||||
* Added new `Twig::addPath()` and `Twig::prependPath()` methods to wrap loader methods and support namespacing [#1604](https://github.com/getgrav/grav/issues/1604)
|
||||
* Added new `array_key_exists()` Twig function wrapper
|
||||
1. [](#bugfix)
|
||||
* Allow `session.timetout` field to be set to `0` via blueprints [#1598](https://github.com/getgrav/grav/issues/1598)
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ class TwigExtension extends \Twig_Extension
|
|||
return [
|
||||
new \Twig_SimpleFunction('array', [$this, 'arrayFunc']),
|
||||
new \Twig_SimpleFunction('array_key_value', [$this, 'arrayKeyValueFunc']),
|
||||
new \Twig_SimpleFunction('array_key_exists', [$this, 'arrayKeyExistsFunc']),
|
||||
new \Twig_simpleFunction('authorize', [$this, 'authorize']),
|
||||
new \Twig_SimpleFunction('debug', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
|
||||
new \Twig_SimpleFunction('dump', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]),
|
||||
|
|
@ -818,6 +819,19 @@ class TwigExtension extends \Twig_Extension
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if an array key exists
|
||||
*
|
||||
* @param string $key key of item
|
||||
* @param string $current_array optional array to add to
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function arrayKeyExistsFunc($key, $current_array = null)
|
||||
{
|
||||
return array_key_exists($key, $current_array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string from a value. If the value is array, return it json encoded
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user