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

SonataCacheBundle   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 6 1
A boot() 0 12 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;
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