feature #10439 [FrameworkBundle] Add posibility to specify method and host in router:match command (romainneutron)
This PR was merged into the 2.5-dev branch.
Discussion
----------
[FrameworkBundle] Add posibility to specify method and host in router:match command
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| License | MIT
Replaces #9340
Commits
-------
acc66b9
[FrameworkBundle] Add posibility to specify method and host in router:match command
This commit is contained in:
commit
b7c158a831
@ -13,6 +13,7 @@ namespace Symfony\Bundle\FrameworkBundle\Command;
|
|||||||
|
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use Symfony\Component\Console\Input\ArrayInput;
|
use Symfony\Component\Console\Input\ArrayInput;
|
||||||
use Symfony\Component\Routing\RouterInterface;
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
@ -50,12 +51,16 @@ class RouterMatchCommand extends ContainerAwareCommand
|
|||||||
->setName('router:match')
|
->setName('router:match')
|
||||||
->setDefinition(array(
|
->setDefinition(array(
|
||||||
new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'),
|
new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'),
|
||||||
|
new InputOption('method', null, InputOption::VALUE_REQUIRED, 'Sets the HTTP method', 'GET'),
|
||||||
|
new InputOption('host', null, InputOption::VALUE_REQUIRED, 'Sets the HTTP host', 'localhost'),
|
||||||
))
|
))
|
||||||
->setDescription('Helps debug routes by simulating a path info match')
|
->setDescription('Helps debug routes by simulating a path info match')
|
||||||
->setHelp(<<<EOF
|
->setHelp(<<<EOF
|
||||||
The <info>%command.name%</info> simulates a path info match:
|
The <info>%command.name%</info> simulates a path info match:
|
||||||
|
|
||||||
<info>php %command.full_name% /foo</info>
|
<info>php %command.full_name% /foo</info>
|
||||||
|
or
|
||||||
|
<info>php %command.full_name% /foo --method POST --host symfony.com</info>
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
)
|
)
|
||||||
@ -68,7 +73,11 @@ EOF
|
|||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$router = $this->getContainer()->get('router');
|
$router = $this->getContainer()->get('router');
|
||||||
$matcher = new TraceableUrlMatcher($router->getRouteCollection(), $router->getContext());
|
$context = $router->getContext();
|
||||||
|
$context->setMethod($input->getOption('method'));
|
||||||
|
$context->setHost($input->getOption('host'));
|
||||||
|
|
||||||
|
$matcher = new TraceableUrlMatcher($router->getRouteCollection(), $context);
|
||||||
|
|
||||||
$traces = $matcher->getTraces($input->getArgument('path_info'));
|
$traces = $matcher->getTraces($input->getArgument('path_info'));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user