Skip to content

Commit a01f87f

Browse files
committed
Merge branch '3.0' into 3.1
2 parents f19328b + bfcafee commit a01f87f

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

book/http_cache.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ as `Varnish`_, `Squid in reverse proxy mode`_, and the Symfony reverse proxy.
9393
Types of Caches
9494
~~~~~~~~~~~~~~~
9595

96-
But a gateway cache isn't the only type of cache. In fact, the HTTP cache
97-
headers sent by your application are consumed and interpreted by up to three
98-
different types of caches:
96+
A gateway cache isn't the only type of cache. In fact, the HTTP cache headers
97+
sent by your application are consumed and interpreted by up to three different
98+
types of caches:
9999

100100
* *Browser caches*: Every browser comes with its own local cache that is
101101
mainly useful for when you hit "back" or for images and other assets.

components/console/events.rst

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,36 @@ C/C++ standard.::
8383
}
8484
});
8585

86+
The ``ConsoleEvents::EXCEPTION`` Event
87+
--------------------------------------
88+
89+
**Typical Purposes**: Handle exceptions thrown during the execution of a
90+
command.
91+
92+
Whenever an exception is thrown by a command, the ``ConsoleEvents::EXCEPTION``
93+
event is dispatched. A listener can wrap or change the exception or do
94+
anything useful before the exception is thrown by the application.
95+
96+
Listeners receive a
97+
:class:`Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent` event::
98+
99+
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
100+
use Symfony\Component\Console\ConsoleEvents;
101+
102+
$dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
103+
$output = $event->getOutput();
104+
105+
$command = $event->getCommand();
106+
107+
$output->writeln(sprintf('Oops, exception thrown while running command <info>%s</info>', $command->getName()));
108+
109+
// get the current exit code (the exception code or the exit code set by a ConsoleEvents::TERMINATE event)
110+
$exitCode = $event->getExitCode();
111+
112+
// change the exception to another one
113+
$event->setException(new \LogicException('Caught exception', $exitCode, $event->getException()));
114+
});
115+
86116
The ``ConsoleEvents::TERMINATE`` Event
87117
--------------------------------------
88118

@@ -121,34 +151,4 @@ Listeners receive a
121151
It is then dispatched just after the ``ConsoleEvents::EXCEPTION`` event.
122152
The exit code received in this case is the exception code.
123153

124-
The ``ConsoleEvents::EXCEPTION`` Event
125-
--------------------------------------
126-
127-
**Typical Purposes**: Handle exceptions thrown during the execution of a
128-
command.
129-
130-
Whenever an exception is thrown by a command, the ``ConsoleEvents::EXCEPTION``
131-
event is dispatched. A listener can wrap or change the exception or do
132-
anything useful before the exception is thrown by the application.
133-
134-
Listeners receive a
135-
:class:`Symfony\\Component\\Console\\Event\\ConsoleExceptionEvent` event::
136-
137-
use Symfony\Component\Console\Event\ConsoleExceptionEvent;
138-
use Symfony\Component\Console\ConsoleEvents;
139-
140-
$dispatcher->addListener(ConsoleEvents::EXCEPTION, function (ConsoleExceptionEvent $event) {
141-
$output = $event->getOutput();
142-
143-
$command = $event->getCommand();
144-
145-
$output->writeln(sprintf('Oops, exception thrown while running command <info>%s</info>', $command->getName()));
146-
147-
// get the current exit code (the exception code or the exit code set by a ConsoleEvents::TERMINATE event)
148-
$exitCode = $event->getExitCode();
149-
150-
// change the exception to another one
151-
$event->setException(new \LogicException('Caught exception', $exitCode, $event->getException()));
152-
});
153-
154154
.. _`reserved exit codes`: http://www.tldp.org/LDP/abs/html/exitcodes.html

0 commit comments

Comments
 (0)