Completed
Push — master ( fe1dad...5b05e2 )
by Eric
07:08
created

FormExtraHelper::javascript()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Ivory Form Extra package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\FormExtraBundle\Templating;
13
14
use Symfony\Component\Form\FormRendererInterface;
15
use Symfony\Component\Form\FormView;
16
use Symfony\Component\Templating\Helper\Helper;
17
18
/**
19
 * Form Extra helper.
20
 *
21
 * @author GeLo <[email protected]>
22
 */
23
class FormExtraHelper extends Helper
24
{
25
    /** @var \Symfony\Component\Form\FormRendererInterface */
26
    private $renderer;
27
28
    /**
29
     * Creates a Form Javascript helper.
30
     *
31
     * @param \Symfony\Component\Form\FormRendererInterface $renderer The form renderer.
32
     */
33
    public function __construct(FormRendererInterface $renderer)
34
    {
35
        $this->renderer = $renderer;
36
    }
37
38
    /**
39
     * Renders a form javascript fragment.
40
     *
41
     * @param FormView $view      The form view.
42
     * @param array    $variables The extra variables
43
     *
44
     * @return string The rendered form javascript fragment.
45
     */
46
    public function javascript(FormView $view, array $variables = array())
47
    {
48
        return $this->renderer->searchAndRenderBlock($view, 'javascript', $variables);
49
    }
50
51
    /**
52
     * Renders a form stylesheet fragment.
53
     *
54
     * @param FormView $view      The form view.
55
     * @param array    $variables The extra variables
56
     *
57
     * @return string The rendered form stylesheet fragment.
58
     */
59
    public function stylesheet(FormView $view, array $variables = array())
60
    {
61
        return $this->renderer->searchAndRenderBlock($view, 'stylesheet', $variables);
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function getName()
68
    {
69
        return 'ivory_form_extra';
70
    }
71
}
72