Completed
Pull Request — master (#18)
by Paulo Rodrigues
03:15
created

RjFrontendBundle::addConsoleHelpers()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

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 6
ccs 0
cts 0
cp 0
rs 9.4286
cc 2
eloc 3
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
            $app->getHelperSet()->set($app->getContainer()->get('rj_frontend.console.helper.question_legacy'), 'question');
0 ignored issues
show
Bug introduced by
The method getContainer() does not seem to exist on object<Symfony\Bundle\Fr...le\Console\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
        }
40
    }
41
}
42