Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions create_framework/event_dispatcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ the registration of a listener for the ``response`` event::

if ($response->isRedirection()
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
|| 'html' !== $event->getRequest()->getRequestFormat()
|| 'html' !== $event->getRequest()->getRequestedResponseFormat()
) {
return;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ Let's refactor the code a bit by moving the Google listener to its own class::

if ($response->isRedirection()
|| ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html'))
|| 'html' !== $event->getRequest()->getRequestFormat()
|| 'html' !== $event->getRequest()->getRequestedResponseFormat()
) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions templating/formats.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ pattern is to do the following::
// retrieve the article based on $slug
$article = ...;

$format = $request->getRequestFormat();
$format = $request->getRequestedResponseFormat();

return $this->render('article/show.'.$format.'.twig', array(
'article' => $article,
));
}
}

The ``getRequestFormat()`` on the ``Request`` object defaults to ``html``,
The ``getRequestedResponseFormat()`` on the ``Request`` object defaults to ``html``,
but can return any other format based on the format requested by the user.
The request format is most often managed by the routing, where a route can
be configured so that ``/about-us`` sets the request format to ``html`` while
Expand Down