Skip to content

[FrameworkBundle] Add posibility to specify method and host in router:match command #10439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[FrameworkBundle] Add posibility to specify method and host in router…
…:match command
  • Loading branch information
pmartelletti authored and romainneutron committed Mar 13, 2014
commit acc66b9d72f61803ec5ff4f156768e86b3962ef8
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Routing\RouterInterface;
Expand Down Expand Up @@ -50,12 +51,16 @@ protected function configure()
->setName('router:match')
->setDefinition(array(
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'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the default should be to keep the default values set in the context already (the default host is configurable through a DIC parameter) instead of forcing it to locahost

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, also there is no support for schemes yet

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabpot does it need an update then ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

))
->setDescription('Helps debug routes by simulating a path info match')
->setHelp(<<<EOF
The <info>%command.name%</info> simulates a path info match:

<info>php %command.full_name% /foo</info>
or
<info>php %command.full_name% /foo --method POST --host symfony.com</info>

EOF
)
Expand All @@ -68,7 +73,11 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$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'));

Expand Down