Completed
Push — master ( 1798f9...8b113a )
by Paulo Rodrigues
07:08
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 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 0
cp 0
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
crap 6
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