Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a088687

Browse files
committed
minor #6250 [Cookbook][Console] remove note about memory spool handling on CLI (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [Cookbook][Console] remove note about memory spool handling on CLI We added this note a long time ago in #4117, but I think we can now safely remove this part. Commits ------- 5eff7fd remove note about memory spool handling on CLI
2 parents 45797b3 + 5eff7fd commit a088687

File tree

5 files changed

+6
-46
lines changed

5 files changed

+6
-46
lines changed

book/routing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ to ``generate()``:
15141514
The host that's used when generating an absolute URL is automatically
15151515
detected using the current ``Request`` object. When generating absolute
15161516
URLs from outside the web context (for instance in a console command) this
1517-
doesn't work. See :doc:`/cookbook/console/sending_emails` to learn how to
1517+
doesn't work. See :doc:`/cookbook/console/request_context` to learn how to
15181518
solve this problem.
15191519

15201520
Summary

cookbook/console/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ Console
77
console_command
88
usage
99
command_in_controller
10-
sending_emails
10+
request_context
1111
logging

cookbook/console/sending_emails.rst renamed to cookbook/console/request_context.rst

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
.. index::
2-
single: Console; Sending emails
32
single: Console; Generating URLs
43

5-
How to Generate URLs and Send Emails from the Console
6-
=====================================================
4+
How to Generate URLs from the Console
5+
=====================================
76

87
Unfortunately, the command line context does not know about your VirtualHost
98
or domain name. This means that if you generate absolute URLs within a
@@ -84,43 +83,3 @@ from the ``router`` service and override its settings::
8483
// ... your code here
8584
}
8685
}
87-
88-
Using Memory Spooling
89-
---------------------
90-
91-
.. versionadded:: 2.3
92-
When using Symfony 2.3+ and SwiftmailerBundle 2.3.5+, the memory spool is now
93-
handled automatically in the CLI and the code below is not necessary anymore.
94-
95-
Sending emails in a console command works the same way as described in the
96-
:doc:`/cookbook/email/email` cookbook except if memory spooling is used.
97-
98-
When using memory spooling (see the :doc:`/cookbook/email/spool` cookbook for more
99-
information), you must be aware that because of how Symfony handles console
100-
commands, emails are not sent automatically. You must take care of flushing
101-
the queue yourself. Use the following code to send emails inside your
102-
console command::
103-
104-
$message = new \Swift_Message();
105-
106-
// ... prepare the message
107-
108-
$container = $this->getContainer();
109-
$mailer = $container->get('mailer');
110-
111-
$mailer->send($message);
112-
113-
// now manually flush the queue
114-
$spool = $mailer->getTransport()->getSpool();
115-
$transport = $container->get('swiftmailer.transport.real');
116-
117-
$spool->flushQueue($transport);
118-
119-
Another option is to create an environment which is only used by console
120-
commands and uses a different spooling method.
121-
122-
.. note::
123-
124-
Taking care of the spooling is only needed when memory spooling is used.
125-
If you are using file spooling (or no spooling at all), there is no need
126-
to flush the queue manually within the command.

cookbook/map.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* :doc:`/cookbook/console/console_command`
4646
* :doc:`/cookbook/console/usage`
4747
* :doc:`/cookbook/console/command_in_controller`
48-
* :doc:`/cookbook/console/sending_emails`
48+
* :doc:`/cookbook/console/request_context`
4949
* :doc:`/cookbook/console/logging`
5050

5151
* :doc:`/cookbook/controller/index`

redirection_map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/book/stable_api /contributing/code/bc
22
/book/internals /reference/events
3+
/cookbook/console/sending_emails /cookbook/console/request_context
34
/cookbook/deployment-tools /cookbook/deployment/tools
45
/cookbook/doctrine/migrations /bundles/DoctrineFixturesBundle/index
56
/cookbook/doctrine/doctrine_fixtures /bundles/DoctrineFixturesBundle/index

0 commit comments

Comments
 (0)