forked from psrpinto/frontend-bundle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RjFrontendBundle.php
42 lines (35 loc) · 1.3 KB
/
RjFrontendBundle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Rj\FrontendBundle;
use Rj\FrontendBundle\Util\Util;
use Rj\FrontendBundle\DependencyInjection\Compiler\Packages\AssetCompilerPass;
use Rj\FrontendBundle\DependencyInjection\Compiler\Packages\TemplatingCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\Console\Application;
use Symfony\Bundle\FrameworkBundle\Console\Application as FrameworkApplication;
class RjFrontendBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
if (Util::hasAssetComponent()) {
$container->addCompilerPass(new AssetCompilerPass());
} else {
$container->addCompilerPass(new TemplatingCompilerPass());
}
}
public function registerCommands(Application $app)
{
if ($app instanceof FrameworkApplication) {
$this->addConsoleHelpers($app);
}
return parent::registerCommands($app);
}
private function addConsoleHelpers(FrameworkApplication $app)
{
if (!Util::hasQuestionHelper()) {
$helper = $app->getKernel()->getContainer()->get('rj_frontend.console.helper.question_legacy');
$app->getHelperSet()->set($helper, 'question');
}
}
}