Skip to content

Commit 1b5f63f

Browse files
committed
[FrameworkBundle] Added isEnabled to Router commands, fixes #1467
1 parent 6d8a9f6 commit 1b5f63f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

Command/RouterApacheDumperCommand.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Output\OutputInterface;
1818
use Symfony\Component\Console\Output\Output;
1919
use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper;
20+
use Symfony\Component\Routing\RouterInterface;
2021

2122
/**
2223
* RouterApacheDumperCommand.
@@ -25,6 +26,21 @@
2526
*/
2627
class RouterApacheDumperCommand extends ContainerAwareCommand
2728
{
29+
/**
30+
* {@inheritDoc}
31+
*/
32+
public function isEnabled()
33+
{
34+
if (!$this->getContainer()->has('router')) {
35+
return false;
36+
}
37+
$router = $this->getContainer()->get('router');
38+
if (!$router instanceof RouterInterface) {
39+
return false;
40+
}
41+
return parent::isEnabled();
42+
}
43+
2844
/**
2945
* @see Command
3046
*/

Command/RouterDebugCommand.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\Console\Output\OutputInterface;
1818
use Symfony\Component\Console\Output\Output;
1919
use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper;
20+
use Symfony\Component\Routing\RouterInterface;
2021

2122
/**
2223
* A console command for retrieving information about routes
@@ -25,6 +26,21 @@
2526
*/
2627
class RouterDebugCommand extends ContainerAwareCommand
2728
{
29+
/**
30+
* {@inheritDoc}
31+
*/
32+
public function isEnabled()
33+
{
34+
if (!$this->getContainer()->has('router')) {
35+
return false;
36+
}
37+
$router = $this->getContainer()->get('router');
38+
if (!$router instanceof RouterInterface) {
39+
return false;
40+
}
41+
return parent::isEnabled();
42+
}
43+
2844
/**
2945
* @see Command
3046
*/

0 commit comments

Comments
 (0)