Skip to content

Commit acc66b9

Browse files
pmartellettiromainneutron
authored andcommitted
[FrameworkBundle] Add posibility to specify method and host in router:match command
1 parent c14d67c commit acc66b9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Console\Input\InputArgument;
1515
use Symfony\Component\Console\Input\InputInterface;
16+
use Symfony\Component\Console\Input\InputOption;
1617
use Symfony\Component\Console\Output\OutputInterface;
1718
use Symfony\Component\Console\Input\ArrayInput;
1819
use Symfony\Component\Routing\RouterInterface;
@@ -50,12 +51,16 @@ protected function configure()
5051
->setName('router:match')
5152
->setDefinition(array(
5253
new InputArgument('path_info', InputArgument::REQUIRED, 'A path info'),
54+
new InputOption('method', null, InputOption::VALUE_REQUIRED, 'Sets the HTTP method', 'GET'),
55+
new InputOption('host', null, InputOption::VALUE_REQUIRED, 'Sets the HTTP host', 'localhost'),
5356
))
5457
->setDescription('Helps debug routes by simulating a path info match')
5558
->setHelp(<<<EOF
5659
The <info>%command.name%</info> simulates a path info match:
5760
5861
<info>php %command.full_name% /foo</info>
62+
or
63+
<info>php %command.full_name% /foo --method POST --host symfony.com</info>
5964
6065
EOF
6166
)
@@ -68,7 +73,11 @@ protected function configure()
6873
protected function execute(InputInterface $input, OutputInterface $output)
6974
{
7075
$router = $this->getContainer()->get('router');
71-
$matcher = new TraceableUrlMatcher($router->getRouteCollection(), $router->getContext());
76+
$context = $router->getContext();
77+
$context->setMethod($input->getOption('method'));
78+
$context->setHost($input->getOption('host'));
79+
80+
$matcher = new TraceableUrlMatcher($router->getRouteCollection(), $context);
7281

7382
$traces = $matcher->getTraces($input->getArgument('path_info'));
7483

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy