Completed
Pull Request — master (#29)
by Paulo Rodrigues
07:22 queued 01:27
created

RjFrontendBundle::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Rj\FrontendBundle;
4
5
use Rj\FrontendBundle\DependencyInjection\Compiler\AssetCompilerPass;
6
use Rj\FrontendBundle\Util\Util;
7
use Symfony\Component\DependencyInjection\ContainerBuilder;
8
use Symfony\Component\HttpKernel\Bundle\Bundle;
9
use Symfony\Component\Console\Application;
10
use Symfony\Bundle\FrameworkBundle\Console\Application as FrameworkApplication;
11
12
class RjFrontendBundle extends Bundle
13
{
14 12
    public function build(ContainerBuilder $container)
15
    {
16 12
        parent::build($container);
17
18 12
        $container->addCompilerPass(new AssetCompilerPass());
19 12
    }
20
21
    public function registerCommands(Application $app)
22
    {
23
        if ($app instanceof FrameworkApplication) {
24
            $this->addConsoleHelpers($app);
25
        }
26
27
        return parent::registerCommands($app);
28
    }
29
30
    private function addConsoleHelpers(FrameworkApplication $app)
31
    {
32
        if (!Util::hasQuestionHelper()) {
33
            $helper = $app->getKernel()->getContainer()->get('rj_frontend.console.helper.question_legacy');
34
            $app->getHelperSet()->set($helper, 'question');
35
        }
36
    }
37
}
38