Completed
Push — master ( 1798f9...8b113a )
by Paulo Rodrigues
07:08
created

RjFrontendBundle   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 9

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 6
c 5
b 0
f 1
lcom 0
cbo 9
dl 0
loc 30
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 10 2
A registerCommands() 0 8 2
A addConsoleHelpers() 0 7 2
1
<?php
2
3
namespace Rj\FrontendBundle;
4
5
use Rj\FrontendBundle\Util\Util;
6
use Rj\FrontendBundle\DependencyInjection\Compiler\Packages\AssetCompilerPass;
7
use Rj\FrontendBundle\DependencyInjection\Compiler\Packages\TemplatingCompilerPass;
8
use Symfony\Component\DependencyInjection\ContainerBuilder;
9
use Symfony\Component\HttpKernel\Bundle\Bundle;
10
use Symfony\Component\Console\Application;
11
use Symfony\Bundle\FrameworkBundle\Console\Application as FrameworkApplication;
12
13 22
class RjFrontendBundle extends Bundle
14
{
15 22
    public function build(ContainerBuilder $container)
16
    {
17 22
        parent::build($container);
18 11
19
        if (Util::hasAssetComponent()) {
20 11
            $container->addCompilerPass(new AssetCompilerPass());
21
        } else {
22 22
            $container->addCompilerPass(new TemplatingCompilerPass());
23
        }
24
    }
25
26
    public function registerCommands(Application $app)
27
    {
28
        if ($app instanceof FrameworkApplication) {
29
            $this->addConsoleHelpers($app);
30
        }
31
32
        return parent::registerCommands($app);
33
    }
34
35
    private function addConsoleHelpers(FrameworkApplication $app)
36
    {
37
        if (!Util::hasQuestionHelper()) {
38
            $helper = $app->getKernel()->getContainer()->get('rj_frontend.console.helper.question_legacy');
39
            $app->getHelperSet()->set($helper, 'question');
40
        }
41
    }
42
}
43