Completed
Pull Request — master (#29)
by Paulo Rodrigues
04:54
created

RjFrontendBundle::addConsoleHelpers()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
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