Produced by OmniGraffle 6.0.3 2014-11-03 12:08ZCanvas 1Layer 12. renderResponse()Select page display variantIs a#type ‘page’ render array?hook_page_attachments()hook_page_(top|bottom)()Example: BlockPageVariant selected.drupal_render() formain contentYesNoBuild page display variantThe result of a built page display variant is a #type ‘page’ render array.hook_page_attachments() operates on #type ‘page’.The main content must already be rendered, because it might set thepage title.drupal_render() of entire HTML documentOnly accepts render arrays of #type ‘page’!Wrap in #type ‘html’hook_page_top() and hook_page_bottom() operate on #type ‘html’.Example: response for the path /admin.Renders the 3 parts of the HTML body: page_top, page, page_bottom(where page corresponds to #type ‘page’ and hence page.html.twig).Then renders the entire HTML (i.e. the html.html.twig template).drupal_render() formain contentAdd InsertCommandnew AjaxResponse()Get dialog options from RequestCalculate title if not provided by main contentCalculate title if not provided by main contentdrupal_render() formain contentAdd OpenDialogCmdnew AjaxResponse()The flow for all four formats supported in core in their respect isdisplayed next, but the explanations below only apply to theHtmlController!If an unsupported format was negotiated, a 406 response is generated. new Response()5. Calling the Controller6. The kernel.view Event7. The kernel.response EventDialogRendererModalRendererHtmlRendererAjaxRendererNoResponseInitialize the corresponding main content rendererIs render array?YesMain content renderer for request format exists?YesCall ::renderResponse()Set Response on EventGenerate 406 ResponseNoController returns either:No1. prepare() helperCalculate title if not provided by main contentdrupal_render() formain contentAdd OpenModalDialogCmdnew AjaxResponse()format = ‘ajax’format = ‘modal’MainContentViewSubscriberResponseResponseResponsemain content renderersformat = ‘html’format = ‘dialog’\D\s\C\SystemController::systemAdminMenuBlockPage is called, itreturns a render array with no #type.MainContentViewSubscriber only handles render arrays!If it’s anything else (e.g. an object), then it’s up to another VIEW eventsubscriber to turn it into a Response.MainContentViewSubscriber looks at the available main contentrenderer services. These are tagged with render.main_content_renderer.Contributed modules can additional renderers.Example: GET /admin.HTTP request1. The kernel.request eventDetermine route & controllerHTTP responseNegotiate formatRequest handling and rendering flowExample: /admin path system.admin routeThat route has the following attributes: _content: '\D\s\C\SystemController::systemAdminMenuBlockPage' _title: ‘Administration’ExplanationKernelEvents::REQUEST2. Resolve the Controller3. The kernel.controller eventSee http://symfony.com/doc/2.5/components/http_kernel/introduction.html for more details — this shows the same steps.4. Getting the Controller ArgumentsYesindex.php3. Call Response::prepare()2. Call HttpKernel::handle()1. Create Request from globals4. Call Response::send()5. Call HttpKernel::terminate()HttpKernel::handle()Symfony (HttpKernel)Drupal (Controller, MainContentViewSubscriber, main content renderers)Event handlingKernelEvents::CONTROLLERSome parts are greyed out because they’re of lesser importance: they do happen, but are not crucial for understanding the flow.Typically, the format will be html, but it could also beajax, dialog, modal, json, hal_json, and more. See: Symfony’s Request::setFormat()._controller is set to '\D\s\C\SystemController::systemAdminMenuBlockPage'KernelEvents::VIEWSELECT_PAGE_DISPLAY_VARIANTKernelEvents::TERMINATEKernelEvents::RESPONSEResponseIs Response?render arrayobject with associated kernel.view event subscriberColored overlaid arrows: showing the flow of the different types of Controller return values.Typical flow