16. This is what Your App is about!
Request
Response
17. “(…) the goal of your
application is always to
interpret a request and
create the appropriate
response based on your
application logic.”
Symfony.com
58. “The HttpKernel
component provides a
structured process for
converting a Request into
a Response by making use
of the EventDispatcher.”
Symfony.com
63. “The EventDispatcher
component provides tools
that allow your application
components to communicate
with each other by
dispatching events and
listening to them.”
Symfony.com
65. $dispatcher
=
new
EventDispatcher();
$dispatcher-‐>addListener(
'foo.action',
function
(Event
$event)
{
//
do
whatever
you
need
});
$event
=
new
Event();
$dispatcher-‐>dispatch('foo.action',
$event);
70. public
function
onKernelRequest(GetResponseEvent
$event)
{
$request
=
$event-‐>getRequest();
if
($request-‐>query-‐>get('name')
===
'Kacper')
{
$event-‐>setResponse(
new
Response("We
don't
like
you!")
);
}
}