diff --git a/EMS/common-bundle/src/Twig/CommonExtension.php b/EMS/common-bundle/src/Twig/CommonExtension.php index 6cfd0f0e2..9931989ad 100644 --- a/EMS/common-bundle/src/Twig/CommonExtension.php +++ b/EMS/common-bundle/src/Twig/CommonExtension.php @@ -63,6 +63,7 @@ public function getFilters(): array new TwigFilter('ems_color', fn ($color) => new Color($color)), new TwigFilter('ems_array_intersect', $this->arrayIntersect(...)), new TwigFilter('ems_array_merge_recursive', $this->arrayMergeRecursive(...)), + new TwigFilter('ems_in_array', $this->inArray(...)), // deprecated new TwigFilter('array_key', $this->arrayKey(...), ['deprecated' => true, 'alternative' => 'ems_array_key']), new TwigFilter('format_bytes', Converter::formatBytes(...), ['deprecated' => true, 'alternative' => 'ems_format_bytes']), @@ -70,6 +71,7 @@ public function getFilters(): array new TwigFilter('emsch_ouuid', $this->getOuuid(...), ['deprecated' => true, 'alternative' => 'ems_ouuid']), new TwigFilter('array_intersect', $this->arrayIntersect(...), ['deprecated' => true, 'alternative' => 'ems_array_intersect']), new TwigFilter('merge_recursive', $this->arrayMergeRecursive(...), ['deprecated' => true, 'alternative' => 'ems_array_merge_recursive']), + new TwigFilter('inArray', $this->inArray(...), ['deprecated' => true, 'alternative' => 'ems_in_array']), ]; } @@ -123,4 +125,12 @@ public function arrayMergeRecursive(array ...$arrays): array { return \array_merge_recursive($arrays); } + + /** + * @param array $haystack + */ + public function inArray(mixed $needle, array $haystack): bool + { + return false !== \array_search($needle, $haystack, true); + } } diff --git a/EMS/core-bundle/src/Twig/AppExtension.php b/EMS/core-bundle/src/Twig/AppExtension.php index df3087148..7afd57bab 100644 --- a/EMS/core-bundle/src/Twig/AppExtension.php +++ b/EMS/core-bundle/src/Twig/AppExtension.php @@ -132,7 +132,6 @@ public function getFunctions(): array public function getFilters(): array { return [ - new TwigFilter('inArray', $this->inArray(...)), new TwigFilter('firstInArray', $this->firstInArray(...)), new TwigFilter('md5', $this->md5(...)), new TwigFilter('convertJavaDateFormat', $this->convertJavaDateFormat(...)), @@ -1027,14 +1026,6 @@ public function getTimeFieldTimeFormat(array $options): string return TimeFieldType::getFormat($options); } - /** - * @param array $haystack - */ - public function inArray(mixed $needle, array $haystack): bool - { - return false !== \array_search($needle, $haystack); - } - /** * @param array $haystack */ diff --git a/docs/upgrade.md b/docs/upgrade.md index cf3dfe795..78252773d 100644 --- a/docs/upgrade.md +++ b/docs/upgrade.md @@ -48,6 +48,7 @@ E.g.: * `emsch_ouuid` must be replaced by `ems_ouuid` * `array_intersect` must be replaced by `ems_array_intersect` * `merge_recursive` must be replaced by `ems_array_merge_recursive` +* `inArray` must be replaced by `ems_in_array` ### Deprecated twig function