Completed
Push — 2.x ( 58f97c...149832 )
by Sullivan
11s
created

SonataCacheBundle::boot()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 12
rs 9.4285
cc 3
eloc 6
nc 3
nop 0
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;
13
14
use Sonata\CacheBundle\DependencyInjection\Compiler\CacheCompilerPass;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\HttpKernel\Bundle\Bundle;
17
18
class SonataCacheBundle extends Bundle
0 ignored issues
show
Bug introduced by
There is one abstract method setContainer in this class; you could implement it, or declare this class as abstract.
Loading history...
19
{
20
    public function build(ContainerBuilder $container)
21
    {
22
        parent::build($container);
23
24
        $container->addCompilerPass(new CacheCompilerPass());
25
    }
26
27
    public function boot()
28
    {
29
        $baseTemplateClass = $this->container->get('twig')->getBaseTemplateClass();
0 ignored issues
show
Bug introduced by
The property container does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
30
31
        if (empty($baseTemplateClass)) {
32
            return;
33
        }
34
35
        if (method_exists($baseTemplateClass, 'attachRecorder')) {
36
            call_user_func(array($baseTemplateClass, 'attachRecorder'), $this->container->get('sonata.cache.recorder'));
37
        }
38
    }
39
}
40