![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mautic.corals.io/app/bundles/CoreBundle/Twig/Extension/ |
<?php declare(strict_types=1); namespace Mautic\CoreBundle\Twig\Extension; use Mautic\FormBundle\Helper\FormFieldHelper; use Symfony\Component\Form\FormView; use Twig\Extension\AbstractExtension; use Twig\TwigFunction; class FormExtension extends AbstractExtension { public function getFunctions() { return [ new TwigFunction('formFieldFormatList', [$this, 'formatList'], ['is_safe' => ['all']]), new TwigFunction('formContainsErrors', [$this, 'containsErrors'], ['is_safe' => ['all']]), ]; } /** * @param array<string> $v */ public function formatList(string $format, array $v): string { return FormFieldHelper::formatList($format, $v); } /** * Checks to see if the form and its children has an error. * * @param array<string> $excluding */ public function containsErrors(FormView $form, array $excluding = []): bool { if (count($form->vars['errors'])) { return true; } foreach ($form->children as $key => $child) { if (in_array($key, $excluding)) { continue; } if (isset($child->vars['errors']) && count($child->vars['errors'])) { return true; } if (count($child->children)) { $hasErrors = $this->containsErrors($child); if ($hasErrors) { return true; } } } return false; } }