CsrfTokenExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFilters() 0 6 1
A getCsrfToken() 0 4 1
A getName() 0 4 1
1
<?php
2
3
namespace Admingenerator\GeneratorBundle\Twig\Extension;
4
5
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
6
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
7
8
/**
9
 * @author Stéphane Escandell
10
 */
11
class CsrfTokenExtension extends \Twig_Extension
0 ignored issues
show
Deprecated Code introduced by
The class Twig_Extension has been deprecated with message: since Twig 2.7, use "Twig\Extension\AbstractExtension" instead

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.

Loading history...
12
{
13
    /**
14
     * @var CsrfTokenManagerInterface
15
     */
16
    protected $csrfTokenManager;
17
18
    /**
19
     * @param CsrfTokenManagerInterface $csrfTokenManager
20
     */
21
    public function __construct(CsrfTokenManagerInterface $csrfTokenManager)
22
    {
23
        $this->csrfTokenManager = $csrfTokenManager;
24
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getFilters()
30
    {
31
        return array(
32
            'csrf_token' => new \Twig_SimpleFilter('csrf_token', array($this, 'getCsrfToken')),
0 ignored issues
show
Deprecated Code introduced by
The class Twig_SimpleFilter has been deprecated with message: since Twig 2.7, use "Twig\TwigFilter" instead

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.

Loading history...
33
        );
34
    }
35
36
    public function getCsrfToken($intention)
37
    {
38
        return $this->csrfTokenManager->getToken($intention);
39
    }
40
41
    /**
42
     * Returns the name of the extension.
43
     *
44
     * @return string The extension name
45
     */
46
    public function getName()
47
    {
48
        return 'admingenerator_csrf';
49
    }
50
}
51