Skip to content

Commit f884555

Browse files
committed
minor #8839 Improved the example to generate URLs in the console (javiereguiluz)
This PR was merged into the 2.7 branch. Discussion ---------- Improved the example to generate URLs in the console This fixes #8827 and a minor issue (code was tabulated with 3 white spaces). When merging in 4.0, the code must be tweaked to use `$this->router` variable instead of `$router`. Commits ------- c1fc868 Improved the example to generate URLs in the console
2 parents 2dc7830 + c1fc868 commit f884555

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

console/request_context.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,13 @@ from the ``router`` service and override its settings::
7272
{
7373
protected function execute(InputInterface $input, OutputInterface $output)
7474
{
75-
$context = $this->getContainer()->get('router')->getContext();
75+
$router = $this->getContainer()->get('router');
76+
$context = $router->getContext();
7677
$context->setHost('example.com');
7778
$context->setScheme('https');
7879
$context->setBaseUrl('my/path');
7980

80-
// ... your code here
81+
$url = $router->generate('route-name', array('param-name' => 'param-value'));
82+
// ...
8183
}
8284
}

0 commit comments

Comments
 (0)