These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\AdminBundle\Twig; |
||
4 | |||
5 | use Kunstmaan\AdminBundle\Helper\FormHelper; |
||
6 | use Symfony\Component\Form\FormView; |
||
7 | |||
8 | /** |
||
9 | * FormToolsExtension |
||
10 | */ |
||
11 | class FormToolsExtension extends \Twig_Extension |
||
0 ignored issues
–
show
|
|||
12 | { |
||
13 | /** |
||
14 | * @var FormHelper |
||
15 | */ |
||
16 | private $formHelper; |
||
17 | |||
18 | /** |
||
19 | * @param FormHelper $formHelper |
||
20 | */ |
||
21 | public function __construct(FormHelper $formHelper) |
||
22 | { |
||
23 | $this->formHelper = $formHelper; |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * Get Twig functions defined in this extension. |
||
28 | * |
||
29 | * @return array |
||
30 | */ |
||
31 | public function getFunctions() |
||
32 | { |
||
33 | return array( |
||
34 | new \Twig_SimpleFunction('form_errors_recursive', array($this, 'getErrorMessages')), |
||
35 | new \Twig_SimpleFunction('form_has_errors_recursive', array($this, 'hasErrorMessages')), |
||
36 | ); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Return if there are error messages. |
||
41 | * |
||
42 | * @param FormView $formView |
||
43 | * |
||
44 | * @return bool |
||
45 | */ |
||
46 | public function hasErrorMessages(FormView $formView) |
||
47 | { |
||
48 | return $this->formHelper->hasRecursiveErrorMessages($formView); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Get the error messages. |
||
53 | * |
||
54 | * @param FormView[]|FormView $formViews The form views |
||
55 | * @param array &$errors The errors |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | public function getErrorMessages($formViews, array &$errors = array()) |
||
60 | { |
||
61 | return $this->formHelper->getRecursiveErrorMessages($formViews, $errors); |
||
62 | } |
||
63 | } |
||
64 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.