Completed
Push — 2.x-dev-kit ( 6f250c )
by
unknown
02:44
created

TwigTemplate13   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 4
Bugs 2 Features 0
Metric Value
wmc 4
c 4
b 2
f 0
lcom 1
cbo 1
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A attachRecorder() 0 4 1
A getAttribute() 0 10 3
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\CacheBundle\Twig;
13
14
use Sonata\Cache\Invalidation\Recorder;
15
16
abstract class TwigTemplate13 extends \Twig_Template
17
{
18
    /**
19
     * @var \Sonata\Cache\Invalidation\Recorder
20
     */
21
    protected static $recorder;
22
23
    /**
24
     * @static
25
     *
26
     * @param \Sonata\Cache\Invalidation\Recorder $recorder
27
     */
28
    public static function attachRecorder(Recorder $recorder)
29
    {
30
        self::$recorder = $recorder;
31
    }
32
33
    /**
34
     * @param        $object
35
     * @param        $item
36
     * @param array  $arguments
37
     * @param string $type
38
     * @param bool   $isDefinedTest
39
     *
40
     * @return mixed
41
     */
42
    protected function getAttribute($object, $item, array $arguments = array(), $type = \Twig_TemplateInterface::ANY_CALL, $isDefinedTest = false)
43
    {
44
        $attribute = parent::getAttribute($object, $item, $arguments, $type, $isDefinedTest);
45
46
        if (self::$recorder && is_object($object)) {
47
            self::$recorder->add($object);
48
        }
49
50
        return $attribute;
51
    }
52
}
53