13
13
14
14
use Symfony \Component \Console \Input \InputArgument ;
15
15
use Symfony \Component \Console \Input \InputInterface ;
16
+ use Symfony \Component \Console \Input \InputOption ;
16
17
use Symfony \Component \Console \Output \OutputInterface ;
17
18
use Symfony \Component \Console \Input \ArrayInput ;
18
19
use Symfony \Component \Routing \RouterInterface ;
@@ -50,12 +51,16 @@ protected function configure()
50
51
->setName ('router:match ' )
51
52
->setDefinition (array (
52
53
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 ' ),
53
56
))
54
57
->setDescription ('Helps debug routes by simulating a path info match ' )
55
58
->setHelp (<<<EOF
56
59
The <info>%command.name%</info> simulates a path info match:
57
60
58
61
<info>php %command.full_name% /foo</info>
62
+ or
63
+ <info>php %command.full_name% /foo --method POST --host symfony.com</info>
59
64
60
65
EOF
61
66
)
@@ -68,7 +73,11 @@ protected function configure()
68
73
protected function execute (InputInterface $ input ,OutputInterface $ output )
69
74
{
70
75
$ 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 );
72
81
73
82
$ traces =$ matcher ->getTraces ($ input ->getArgument ('path_info ' ));
74
83