Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moving the console generating urls cookbook inside the sending emails…

… cookbook.
  • Loading branch information...
commit 0746fcb7368a883d965acf368476660a5f479897 1 parent cc049d3
@Sgoettschkes Sgoettschkes authored weaverryan committed
View
39 cookbook/console/generating_urls.rst
@@ -1,39 +0,0 @@
-.. index::
- single: Console; Generating URLs
-
-How to generate URLs with a custom Host in Console Commands
-===========================================================
-
-Unfortunately, the command line context does not know about your VirtualHost
-or domain name. This means that if if you generate absolute URLs within a
-Console Command you'll probably end up with something like ``http://localhost/foo/bar``
-which is not very useful.
-
-To fix this, you need to configure the "request context", which is a fancy
-way of saying that you need to configure your environment so that it knows
-what URL it should use when generating URLs.
-
-There are two ways of configuring the request context: at the application level
-and per Command.
-
-Configuring the Request Context per Command
--------------------------------------------
-
-To change it only in one command you can simply fetch the Request Context
-service and override its settings::
-
- // src/Acme/DemoBundle/Command/DemoCommand.php
-
- // ...
- class DemoCommand extends ContainerAwareCommand
- {
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $context = $this->getContainer()->get('router')->getContext();
- $context->setHost('example.com');
- $context->setScheme('https');
-
- // ... your code here
- }
- }
-
View
1  cookbook/console/index.rst
@@ -6,5 +6,4 @@ Console
console_command
usage
- generating_urls
sending_emails
View
41 cookbook/console/sending_emails.rst
@@ -1,8 +1,45 @@
.. index::
single: Console; Sending emails
+ single: Console; Generating URLs
-How to send emails in a console command
-=======================================
+How to generate URLs and send Emails from the Console
+=====================================================
+
+Unfortunately, the command line context does not know about your VirtualHost
+or domain name. This means that if if you generate absolute URLs within a
+Console Command you'll probably end up with something like ``http://localhost/foo/bar``
+which is not very useful.
+
+To fix this, you need to configure the "request context", which is a fancy
+way of saying that you need to configure your environment so that it knows
+what URL it should use when generating URLs.
+
+There are two ways of configuring the request context: at the application level
+(only available in Symfony 2.1+) and per Command.
+
+Configuring the Request Context per Command
+-------------------------------------------
+
+To change it only in one command you can simply fetch the Request Context
+service and override its settings::
+
+ // src/Acme/DemoBundle/Command/DemoCommand.php
+
+ // ...
+ class DemoCommand extends ContainerAwareCommand
+ {
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $context = $this->getContainer()->get('router')->getContext();
+ $context->setHost('example.com');
+ $context->setScheme('https');
+
+ // ... your code here
+ }
+ }
+
+Using Memory Spooling
+---------------------
Sending emails in a console command works the same way as described in the
:doc:`/cookbook/email/email` cookbook except if memory spooling is used.
View
1  cookbook/map.rst.inc
@@ -28,7 +28,6 @@
* :doc:`/cookbook/console/console_command`
* :doc:`/cookbook/console/usage`
- * :doc:`/cookbook/console/generating_urls`
* :doc:`/cookbook/console/sending_emails`
* :doc:`/cookbook/controller/index`
View
3  redirection_map
@@ -16,4 +16,5 @@
/components/event_dispatcher /components/event_dispatcher/introduction
/components/http_foundation /components/http_foundation/introduction
/components/console /components/console/introduction
-/components/routing /components/routing/introduction
+/components/routing /components/routing/introduction
+/cookbook/console/generating_urls /cookbook/console/sending_emails
Please sign in to comment.
Something went wrong with that request. Please try again.