Skip to content

Commit ca90035

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Added note regarding workflow "entered" event being dispatched on creation get/setThrowable
2 parents d91f1c2 + 7ef72fe commit ca90035

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

components/http_kernel.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,22 @@ to the exception.
526526

527527
Each listener to this event is passed a :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent`
528528
object, which you can use to access the original exception via the
529-
:method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getException`
529+
:method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getThrowable`
530530
method. A typical listener on this event will check for a certain type of
531531
exception and create an appropriate error ``Response``.
532532

533+
.. versionadded:: 4.4
534+
535+
The :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getThrowable` and
536+
:method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::setThrowable` methods
537+
were introduced in Symfony 4.4.
538+
539+
.. deprecated:: 4.4
540+
541+
The :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getException` and
542+
:method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::setException` methods
543+
are deprecated since Symfony 4.4.
544+
533545
For example, to generate a 404 page, you might throw a special type of exception
534546
and then add a listener on this event that looks for this exception and
535547
creates and returns a 404 ``Response``. In fact, the HttpKernel component

event_dispatcher.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The most common way to listen to an event is to register an **event listener**::
3535
public function onKernelException(ExceptionEvent $event)
3636
{
3737
// You get the exception object from the received event
38-
$exception = $event->getException();
38+
$exception = $event->getThrowable();
3939
$message = sprintf(
4040
'My Error says: %s with code: %s',
4141
$exception->getMessage(),

reference/events.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,14 @@ sent as response::
239239

240240
public function onKernelException(ExceptionEvent $event)
241241
{
242-
$exception = $event->getException();
242+
$exception = $event->getThrowable();
243243
$response = new Response();
244244
// setup the Response object based on the caught exception
245245
$event->setResponse($response);
246246

247247
// you can alternatively set a new Exception
248248
// $exception = new \Exception('Some special exception');
249-
// $event->setException($exception);
249+
// $event->setThrowable($exception);
250250
}
251251

252252
.. note::

workflow.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,29 +215,29 @@ what actions are allowed on a blog post::
215215

216216
// See all the available transitions for the post in the current state
217217
$transitions = $workflow->getEnabledTransitions($post);
218-
218+
219219
Accessing the Workflow in a Class
220220
---------------------------------
221221

222222
To access workflow inside a class, use dependency injection and inject the
223223
registry in the constructor::
224224

225225
use Symfony\Component\Workflow\Registry;
226-
226+
227227
class MyClass
228228
{
229-
229+
230230
private $workflowRegistry;
231-
231+
232232
public function __construct(Registry $workflowRegistry)
233233
{
234234
$this->workflowRegistry = $workflowRegistry;
235235
}
236-
236+
237237
public function toReview(BlogPost $blogPost)
238238
{
239239
$workflow = $this->workflowRegistry->get($blogPost);
240-
240+
241241
// Update the currentState on the post
242242
try {
243243
$workflow->apply($post, 'to_review');
@@ -339,6 +339,11 @@ order:
339339
The leaving and entering events are triggered even for transitions that stay
340340
in same place.
341341

342+
.. versionadded:: 4.3
343+
344+
Following events are also dispatched when the subject enters the workflow
345+
for the first time: ``workflow.entered`` and ``workflow.[worflow name].entered``.
346+
342347
Here is an example of how to enable logging for every time a "blog_publishing"
343348
workflow leaves a place::
344349

0 commit comments

Comments
 (0)