[FrameworkBundle] Add posibility to specify method and host in router:match command
This commit is contained in:
parent
c14d67c11d
commit
acc66b9d72
@ -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