Completed
Push — async ( 59a193 )
by Eric
14:44
created

CKEditorJavascriptHelper::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Ivory CKEditor 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\CKEditorBundle\Templating;
13
14
use Symfony\Component\Form\FormRendererInterface;
15
use Symfony\Component\Form\FormView;
16
use Symfony\Component\Templating\Helper\Helper;
17
18
/**
19
 * CKEditor Javascript helper.
20
 *
21
 * @author GeLo <[email protected]>
22
 */
23
class CKEditorJavascriptHelper extends Helper
24
{
25
    /** @var \Symfony\Component\Form\FormRendererInterface */
26
    private $renderer;
27
28
    /**
29
     * Creates a CKEditor 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 bool     $prototype TRUE if the form view is a prototype else FALSE.
43
     *
44
     * @return string The rendered form javascript fragment.
45
     */
46
    public function renderJavascript(FormView $view, $prototype = false)
47
    {
48
        return $this->renderer->searchAndRenderBlock($view, $prototype ? 'javascript_prototype' : 'javascript');
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function getName()
55
    {
56
        return 'ivory_ckeditor_javascript';
57
    }
58
}
59