File tree Expand file tree Collapse file tree 1 file changed +17
-15
lines changed Expand file tree Collapse file tree 1 file changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -65,18 +65,20 @@ Configuring the Request Context per Command
65
65
To change it only in one command you can simply fetch the Request Context
66
66
from the ``router `` service and override its settings::
67
67
68
- // src/AppBundle/Command/DemoCommand.php
69
-
70
- // ...
71
- class DemoCommand extends ContainerAwareCommand
72
- {
73
- protected function execute(InputInterface $input, OutputInterface $output)
74
- {
75
- $context = $this->getContainer()->get('router')->getContext();
76
- $context->setHost('example.com');
77
- $context->setScheme('https');
78
- $context->setBaseUrl('my/path');
79
-
80
- // ... your code here
81
- }
82
- }
68
+ // src/AppBundle/Command/DemoCommand.php
69
+
70
+ // ...
71
+ class DemoCommand extends ContainerAwareCommand
72
+ {
73
+ protected function execute(InputInterface $input, OutputInterface $output)
74
+ {
75
+ $router = $this->getContainer()->get('router');
76
+ $context = $router->getContext();
77
+ $context->setHost('example.com');
78
+ $context->setScheme('https');
79
+ $context->setBaseUrl('my/path');
80
+
81
+ $url = $router->generate('route-name', array('param-name' => 'param-value'));
82
+ // ...
83
+ }
84
+ }
You can’t perform that action at this time.
0 commit comments