Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitacc66b9

Browse files
pmartellettiromainneutron
authored andcommitted
[FrameworkBundle] Add posibility to specify method and host in router:match command
1 parentc14d67c commitacc66b9

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
useSymfony\Component\Console\Input\InputArgument;
1515
useSymfony\Component\Console\Input\InputInterface;
16+
useSymfony\Component\Console\Input\InputOption;
1617
useSymfony\Component\Console\Output\OutputInterface;
1718
useSymfony\Component\Console\Input\ArrayInput;
1819
useSymfony\Component\Routing\RouterInterface;
@@ -50,12 +51,16 @@ protected function configure()
5051
->setName('router:match')
5152
->setDefinition(array(
5253
newInputArgument('path_info', InputArgument::REQUIRED,'A path info'),
54+
newInputOption('method',null, InputOption::VALUE_REQUIRED,'Sets the HTTP method','GET'),
55+
newInputOption('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
protectedfunctionexecute(InputInterface$input,OutputInterface$output)
6974
{
7075
$router =$this->getContainer()->get('router');
71-
$matcher =newTraceableUrlMatcher($router->getRouteCollection(),$router->getContext());
76+
$context =$router->getContext();
77+
$context->setMethod($input->getOption('method'));
78+
$context->setHost($input->getOption('host'));
79+
80+
$matcher =newTraceableUrlMatcher($router->getRouteCollection(),$context);
7281

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp