SlideShare a Scribd company logo
Drupal 8 render pipeline
~ Mahesh Salaria (@salaria)
Kelltontech
2. renderResponse()
Select page
display variant
Is a
#type ‘page’
render array?
hook_page_attachments()
hook_page_(top|bottom)()
Example: BlockPageVariant selected.
render()
main content
Yes
No
Build page display
variant The 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 the
page title.
render()
entire HTML document
Only accepts render arrays of #type ‘page’!
Wrap in #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).
render()
main content
Add InsertCommand
new AjaxResponse()
Get dialog options from
Request
Calculate title if not
provided by main content
Calculate title if not
provided by main content
render()
main content
Add OpenDialogCmd
new AjaxResponse()
The flow for all four formats supported in core in their respect is
displayed next, but the explanations below only apply to the
HtmlController!
If an unsupported format was negotiated, a 406 response is generated.
new HtmlResponse()
5. Calling the Controller
6. The ker nel . vi ew Event
7. The ker nel . r esponse Event
Di al ogRender er Modal Render erHt ml Render er Aj axRender er
No
Response
Initialize the corresponding
main content renderer
Is render array?
Yes
Main content
renderer for request
format exists?
Yes
Call : : r ender Response( )
Set Response on Event
Generate 406
Response
No
Controller returns either:
No
1. prepare() helper
Calculate title if not
provided by main content
render()
main content
Add OpenModalDialogCmd
new AjaxResponse()
f or mat = ‘ aj ax’f or mat = ‘ modal ’
Mai nCont ent Vi ewSubscr i ber
Response
Response
Response
main content renderers
f or mat = ‘ ht ml ’ f or mat = ‘ di al og’
DsCSystemController::systemAdminMenuBlockPage is called, it
returns 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 event
subscriber to turn it into a Response.
MainContentViewSubscriber looks at the available main content
renderer services. These are tagged with render.main_content_renderer.
Contributed modules can additional renderers.
Example: GET /admin.
HTTP request
1. The ker nel . r equest event Determine
route &
controller
HTTP response
Negotiate
format
Request handling and rendering flow
Example: /admin path → system.admin route
That route has the following attributes:
_content: 'DsCSystemController::systemAdminMenuBlockPage'
_title: ‘Administration’
Explanation
KernelEvents::REQUEST
2. Resolve the Controller
3. The ker nel . cont r ol l er event
See http://symfony.com/doc/2.7/components/
http_kernel/introduction.html
for more details — this shows the same steps.
4. Getting the Controller Arguments
Yes
i ndex. php
3. Call Response: : pr epar e( )
2. Call Ht t pKer nel : : handl e( )
1. Create Request from globals
4. Call Response: : send( )
5. Call Ht t pKer nel : : t er mi nat e( )
Ht t pKer nel : : handl e( )
Symfony (HttpKernel) Drupal (Controller, MainContentViewSubscriber, main content renderers)Event handling
KernelEvents::CONTROLLER
Some 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 be
ajax, dialog, modal, json, hal_json, and more.
See: Symfony’s Request::setFormat().
_controller is set to 'DsCSystemController::systemAdminMenuBlockPage'
KernelEvents::VIEW
SELECT_PAGE_DISPLAY_VARIANT
KernelEvents::TERMINATE
Response
Is Response?
render
array
object with
associated
kernel.view
event
subscriber
Colored overlaid arrows: showing the flow of the
different types of Controller return values.
Typical flow
Note that HtmlResponse (as well as AjaxResponse) at this point still
contains attachments: asset libraries, headers … but also placeholders.
…
Return placeholders
unchanged
Si ngl eFl ush ( cor e) Bi gPi pe ( cont r i b) …
Transform placeholders to
BigPipe placeholders
placeholder strategies (HTML responses only)
Is HTML response
and has placeholders
attached?
: : pr ocessPl acehol der s( )
Set final pl acehol der s on
Ht ml Response
Yes
Ht ml Res’ Pl acehol der St r at ’ Sub
Placeholder strategies can transform standard Drupal placeholders
(designed for non-deferred rendering) into other placeholders, which
may be replaced with the final markup using any way possible.
For example: BigPipe, ESI …
ChainedPlaceholderStrategy looks at the available placeholder
strategies. These are tagged with placeholder_strategy.
Contributed modules can additional renderers.
BigPipe is a contrib module during 8.0.x, will likely be in 8.1.x core.
See https://www.drupal.org/project/big_pipe
KernelEvents::RESPONSE
No
Ht ml Res’ At t achment sPr ocessor
Render pl acehol der s
Update HTML to load final assets, set
attached headers on response …
Process all other HtmlResponse attachments: asset libraries, HTML
<head> elements, headers …
BigPipe placeholders rendered at the end of::send(), after most is sent.
HttpKernal Component
• The HttpKernel component provides a structured process for
converting a Request into a Response by making use of the
EventDispatcher component.
• Every HTTP web interaction begins with a request and ends with a
response. Your job as a developer is to create PHP code that reads the
request information (e.g. the URL) and creates and returns a response
(e.g. an HTML page or JSON string).
Routes
• Routes whose controllers return a Response object bypass the
pipeline. They rely directly on the Symfony render pipeline.
• Route whose controllers return the "main content" as a render
array automatically has the ability to be requested in multiple ways: it
can be rendered in a certain format (HTML, JSON …) and/or in a
certain decorated manner (e.g. with blocks around the main content).
Events
• The glue between Symfony and Drupal.
• Triggered by HttpKernel::handle()
Controllers
• Business Logic to send response object or render array or an Object
associated with Event Subscriber.
Content Renderer
• After the controller returned a render array, the VIEW will be
triggered by the HttpKernel, because the controller result is not
a Response, but a render array.
• MainContentViewSubscriber checks whether the negotiated request
format is supported.
• All classes that implement MainContentRendererInterface
• AjaxRenderer
• DialogRenderer
• HtmlRenderer
• ModalRenderer
Placeholder strategies (HTML responses only)
• SingleFlush (Traditional Way)
• BigPipe (https://youtu.be/JwzX0Qv6u3A)
• During rendering, the personalized parts are turned into placeholders.
• By default, Drupal 8 uses the Single Flush strategy (aka "traditional") for replacing the
placeholders. i.e. we don't send a response until we've replaced all placeholders.
• The BigPipe module introduces a new strategy, that allows us to flush the initial page first,
and then stream the replacements for the placeholders.
• This results in hugely improved front-end/perceived performance (watch the 40-second
screencast above).
BigPipe
• BigPipe first breaks web pages into multiple chunks called pagelets
and process into several stages:
• Request parsing: web server parses and sanity checks the HTTP request.
• Data fetching: web server fetches data from storage tier.
• Markup generation: web server generates HTML markup for the response.
• Network transport: the response is transferred from web server to browser.
• CSS downloading: browser downloads CSS required by the page.
• DOM tree construction and CSS styling: browser constructs DOM tree of the document, and
then applies CSS rules on it.
• JavaScript downloading: browser downloads JavaScript resources referenced by the page.
• JavaScript execution: browser executes JavaScript code of the page.
Source: https://www.drupal.org/project/big_pipe
Refrences
• https://www.drupal.org/developing/api/8/render/pipeline
• https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Routing!routi
ng.api.php/group/routing
• http://wimleers.com/talk/drupal-8-render-pipeline
• https://www.drupal.org/project/big_pipe
• https://www.facebook.com/notes/facebook-engineering/bigpipe-
pipelining-web-pages-for-high-performance/389414033919
Discussion!
Thank you 

More Related Content

What's hot

Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
Jordan Silva
 
.NET Core, ASP.NET Core Course, Session 11
.NET Core, ASP.NET Core Course, Session 11.NET Core, ASP.NET Core Course, Session 11
.NET Core, ASP.NET Core Course, Session 11
aminmesbahi
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Guo Albert
 
JavaServer Pages
JavaServer PagesJavaServer Pages
JavaServer Pages
Abdalla Mahmoud
 
Demystifying Drupal AJAX Callback Commands
Demystifying Drupal AJAX Callback CommandsDemystifying Drupal AJAX Callback Commands
Demystifying Drupal AJAX Callback Commands
Michael Miles
 
Introduction to JSP
Introduction to JSPIntroduction to JSP
Introduction to JSP
Geethu Mohan
 
JSP Error handling
JSP Error handlingJSP Error handling
JSP Error handling
kamal kotecha
 
.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10
aminmesbahi
 
Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4
than sare
 
.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13
aminmesbahi
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
Tuna Tore
 
Working with Servlets
Working with ServletsWorking with Servlets
Working with Servlets
People Strategists
 
Android - Saving data
Android - Saving dataAndroid - Saving data
Android - Saving data
Matteo Bonifazi
 
TY.BSc.IT Java QB U1
TY.BSc.IT Java QB U1TY.BSc.IT Java QB U1
TY.BSc.IT Java QB U1
Lokesh Singrol
 
Jsp presentation
Jsp presentationJsp presentation
Jsp presentation
Sher Singh Bardhan
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
Guy Nir
 
SCWCD : The servlet container : CHAP : 4
SCWCD : The servlet container : CHAP : 4SCWCD : The servlet container : CHAP : 4
SCWCD : The servlet container : CHAP : 4
Ben Abdallah Helmi
 
Backendless apps
Backendless appsBackendless apps
Backendless apps
Matteo Bonifazi
 
Learn Drupal 8 Render Pipeline
Learn Drupal 8 Render PipelineLearn Drupal 8 Render Pipeline
Learn Drupal 8 Render Pipeline
Zyxware Technologies
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
BG Java EE Course
 

What's hot (20)

Spring MVC Annotations
Spring MVC AnnotationsSpring MVC Annotations
Spring MVC Annotations
 
.NET Core, ASP.NET Core Course, Session 11
.NET Core, ASP.NET Core Course, Session 11.NET Core, ASP.NET Core Course, Session 11
.NET Core, ASP.NET Core Course, Session 11
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
JavaServer Pages
JavaServer PagesJavaServer Pages
JavaServer Pages
 
Demystifying Drupal AJAX Callback Commands
Demystifying Drupal AJAX Callback CommandsDemystifying Drupal AJAX Callback Commands
Demystifying Drupal AJAX Callback Commands
 
Introduction to JSP
Introduction to JSPIntroduction to JSP
Introduction to JSP
 
JSP Error handling
JSP Error handlingJSP Error handling
JSP Error handling
 
.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10.NET Core, ASP.NET Core Course, Session 10
.NET Core, ASP.NET Core Course, Session 10
 
Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4
 
.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13.NET Core, ASP.NET Core Course, Session 13
.NET Core, ASP.NET Core Course, Session 13
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
Working with Servlets
Working with ServletsWorking with Servlets
Working with Servlets
 
Android - Saving data
Android - Saving dataAndroid - Saving data
Android - Saving data
 
TY.BSc.IT Java QB U1
TY.BSc.IT Java QB U1TY.BSc.IT Java QB U1
TY.BSc.IT Java QB U1
 
Jsp presentation
Jsp presentationJsp presentation
Jsp presentation
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
 
SCWCD : The servlet container : CHAP : 4
SCWCD : The servlet container : CHAP : 4SCWCD : The servlet container : CHAP : 4
SCWCD : The servlet container : CHAP : 4
 
Backendless apps
Backendless appsBackendless apps
Backendless apps
 
Learn Drupal 8 Render Pipeline
Learn Drupal 8 Render PipelineLearn Drupal 8 Render Pipeline
Learn Drupal 8 Render Pipeline
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 

Viewers also liked

Mallikarjun-Ext
Mallikarjun-ExtMallikarjun-Ext
Mallikarjun-Ext
mallikarjun kondikoppa
 
Zet - Osallistavan pelisuunnittelun A-B-C/Hanna Tuohimaa
Zet - Osallistavan pelisuunnittelun A-B-C/Hanna TuohimaaZet - Osallistavan pelisuunnittelun A-B-C/Hanna Tuohimaa
Zet - Osallistavan pelisuunnittelun A-B-C/Hanna Tuohimaa
THL
 
Vuodenvaihde sahkosavukemarkkinat
Vuodenvaihde sahkosavukemarkkinatVuodenvaihde sahkosavukemarkkinat
Vuodenvaihde sahkosavukemarkkinat
THL
 
Sote ja maakuntauudistus HE:n päälinjat ja tilannekatsaus lokakuu 2016 Tuoma...
Sote  ja maakuntauudistus HE:n päälinjat ja tilannekatsaus lokakuu 2016 Tuoma...Sote  ja maakuntauudistus HE:n päälinjat ja tilannekatsaus lokakuu 2016 Tuoma...
Sote ja maakuntauudistus HE:n päälinjat ja tilannekatsaus lokakuu 2016 Tuoma...
Sosiaali- ja terveysministeriö / yleiset
 
Pruning of tomato A Presentation By Mr Allah Dad Khan Former Director General...
Pruning of tomato A Presentation By Mr Allah Dad Khan Former Director General...Pruning of tomato A Presentation By Mr Allah Dad Khan Former Director General...
Pruning of tomato A Presentation By Mr Allah Dad Khan Former Director General...
Mr.Allah Dad Khan
 
Aarnio johdon tietosuojaseminaari
Aarnio johdon tietosuojaseminaariAarnio johdon tietosuojaseminaari
Aarnio johdon tietosuojaseminaari
THL
 
Rose water benefits for skin, eyes A Presentation By Mr Allah Dad Khan Former...
Rose water benefits for skin, eyes A Presentation By Mr Allah Dad Khan Former...Rose water benefits for skin, eyes A Presentation By Mr Allah Dad Khan Former...
Rose water benefits for skin, eyes A Presentation By Mr Allah Dad Khan Former...
Mr.Allah Dad Khan
 
Hodgkin lymphoma
Hodgkin lymphomaHodgkin lymphoma
Hodgkin lymphoma
vbalraam
 
School lunch for children A Presentation By Mr Allah Dad Khan Former Direct...
School lunch for children   A Presentation By Mr Allah Dad Khan Former Direct...School lunch for children   A Presentation By Mr Allah Dad Khan Former Direct...
School lunch for children A Presentation By Mr Allah Dad Khan Former Direct...
Mr.Allah Dad Khan
 
Imn csbrp
Imn csbrpImn csbrp
Imn csbrp
Prasad CSBR
 
Invasion &amp; metastasis csbrp
Invasion &amp; metastasis csbrpInvasion &amp; metastasis csbrp
Invasion &amp; metastasis csbrp
Prasad CSBR
 
Carcinogenesis
CarcinogenesisCarcinogenesis
Carcinogenesis
Chander K Negi
 
General Pharmacology for BPT Students
General Pharmacology for BPT StudentsGeneral Pharmacology for BPT Students
General Pharmacology for BPT Students
Kalaivanisathishr
 
Genetics 1-csbrp
Genetics 1-csbrpGenetics 1-csbrp
Genetics 1-csbrp
Prasad CSBR
 
Satyajit rayloiiuo
Satyajit  rayloiiuoSatyajit  rayloiiuo
Satyajit rayloiiuo
VINAY PAINKRA
 

Viewers also liked (15)

Mallikarjun-Ext
Mallikarjun-ExtMallikarjun-Ext
Mallikarjun-Ext
 
Zet - Osallistavan pelisuunnittelun A-B-C/Hanna Tuohimaa
Zet - Osallistavan pelisuunnittelun A-B-C/Hanna TuohimaaZet - Osallistavan pelisuunnittelun A-B-C/Hanna Tuohimaa
Zet - Osallistavan pelisuunnittelun A-B-C/Hanna Tuohimaa
 
Vuodenvaihde sahkosavukemarkkinat
Vuodenvaihde sahkosavukemarkkinatVuodenvaihde sahkosavukemarkkinat
Vuodenvaihde sahkosavukemarkkinat
 
Sote ja maakuntauudistus HE:n päälinjat ja tilannekatsaus lokakuu 2016 Tuoma...
Sote  ja maakuntauudistus HE:n päälinjat ja tilannekatsaus lokakuu 2016 Tuoma...Sote  ja maakuntauudistus HE:n päälinjat ja tilannekatsaus lokakuu 2016 Tuoma...
Sote ja maakuntauudistus HE:n päälinjat ja tilannekatsaus lokakuu 2016 Tuoma...
 
Pruning of tomato A Presentation By Mr Allah Dad Khan Former Director General...
Pruning of tomato A Presentation By Mr Allah Dad Khan Former Director General...Pruning of tomato A Presentation By Mr Allah Dad Khan Former Director General...
Pruning of tomato A Presentation By Mr Allah Dad Khan Former Director General...
 
Aarnio johdon tietosuojaseminaari
Aarnio johdon tietosuojaseminaariAarnio johdon tietosuojaseminaari
Aarnio johdon tietosuojaseminaari
 
Rose water benefits for skin, eyes A Presentation By Mr Allah Dad Khan Former...
Rose water benefits for skin, eyes A Presentation By Mr Allah Dad Khan Former...Rose water benefits for skin, eyes A Presentation By Mr Allah Dad Khan Former...
Rose water benefits for skin, eyes A Presentation By Mr Allah Dad Khan Former...
 
Hodgkin lymphoma
Hodgkin lymphomaHodgkin lymphoma
Hodgkin lymphoma
 
School lunch for children A Presentation By Mr Allah Dad Khan Former Direct...
School lunch for children   A Presentation By Mr Allah Dad Khan Former Direct...School lunch for children   A Presentation By Mr Allah Dad Khan Former Direct...
School lunch for children A Presentation By Mr Allah Dad Khan Former Direct...
 
Imn csbrp
Imn csbrpImn csbrp
Imn csbrp
 
Invasion &amp; metastasis csbrp
Invasion &amp; metastasis csbrpInvasion &amp; metastasis csbrp
Invasion &amp; metastasis csbrp
 
Carcinogenesis
CarcinogenesisCarcinogenesis
Carcinogenesis
 
General Pharmacology for BPT Students
General Pharmacology for BPT StudentsGeneral Pharmacology for BPT Students
General Pharmacology for BPT Students
 
Genetics 1-csbrp
Genetics 1-csbrpGenetics 1-csbrp
Genetics 1-csbrp
 
Satyajit rayloiiuo
Satyajit  rayloiiuoSatyajit  rayloiiuo
Satyajit rayloiiuo
 

Similar to Drupal8 render pipeline

The Django Book chapter 4 templates (supplement)
The Django Book chapter 4 templates (supplement)The Django Book chapter 4 templates (supplement)
The Django Book chapter 4 templates (supplement)
Vincent Chien
 
6 introduction-php-mvc-cakephp-m6-views-slides
6 introduction-php-mvc-cakephp-m6-views-slides6 introduction-php-mvc-cakephp-m6-views-slides
6 introduction-php-mvc-cakephp-m6-views-slides
MasterCode.vn
 
Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphony
Brahampal Singh
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
ramakesavan
 
react-en.pdf
react-en.pdfreact-en.pdf
react-en.pdf
ssuser65180a
 
Templates, partials and layouts
Templates, partials and layoutsTemplates, partials and layouts
Templates, partials and layouts
Kadiv Vech
 
React js
React jsReact js
React js
Rajesh Kolla
 
React hooks
React hooksReact hooks
React hooks
Ramy ElBasyouni
 
MVC Training Part 1
MVC Training Part 1MVC Training Part 1
MVC Training Part 1
Lee Englestone
 
Adding a view
Adding a viewAdding a view
Adding a view
Nhan Do
 
Template rendering in rails
Template rendering in rails Template rendering in rails
Template rendering in rails
Hung Wu Lo
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
DayNightGaMiNg
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
DayNightGaMiNg
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
janet736113
 
Murach: How to transfer data from controllers
Murach: How to transfer data from controllersMurach: How to transfer data from controllers
Murach: How to transfer data from controllers
MahmoudOHassouna
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
Nitin Tyagi
 
ReactJS.pptx
ReactJS.pptxReactJS.pptx
ReactJS.pptx
SamyakShetty2
 
The Render API in Drupal 7
The Render API in Drupal 7The Render API in Drupal 7
The Render API in Drupal 7
frandoh
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
Alessandro Molina
 
Angular js
Angular jsAngular js
Angular js
Thyda Eng
 

Similar to Drupal8 render pipeline (20)

The Django Book chapter 4 templates (supplement)
The Django Book chapter 4 templates (supplement)The Django Book chapter 4 templates (supplement)
The Django Book chapter 4 templates (supplement)
 
6 introduction-php-mvc-cakephp-m6-views-slides
6 introduction-php-mvc-cakephp-m6-views-slides6 introduction-php-mvc-cakephp-m6-views-slides
6 introduction-php-mvc-cakephp-m6-views-slides
 
Drupal 8 meets to symphony
Drupal 8 meets to symphonyDrupal 8 meets to symphony
Drupal 8 meets to symphony
 
Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes Drupal 7 Theming - Behind the scenes
Drupal 7 Theming - Behind the scenes
 
react-en.pdf
react-en.pdfreact-en.pdf
react-en.pdf
 
Templates, partials and layouts
Templates, partials and layoutsTemplates, partials and layouts
Templates, partials and layouts
 
React js
React jsReact js
React js
 
React hooks
React hooksReact hooks
React hooks
 
MVC Training Part 1
MVC Training Part 1MVC Training Part 1
MVC Training Part 1
 
Adding a view
Adding a viewAdding a view
Adding a view
 
Template rendering in rails
Template rendering in rails Template rendering in rails
Template rendering in rails
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
Murach: How to transfer data from controllers
Murach: How to transfer data from controllersMurach: How to transfer data from controllers
Murach: How to transfer data from controllers
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
 
ReactJS.pptx
ReactJS.pptxReactJS.pptx
ReactJS.pptx
 
The Render API in Drupal 7
The Render API in Drupal 7The Render API in Drupal 7
The Render API in Drupal 7
 
TurboGears2 Pluggable Applications
TurboGears2 Pluggable ApplicationsTurboGears2 Pluggable Applications
TurboGears2 Pluggable Applications
 
Angular js
Angular jsAngular js
Angular js
 

Recently uploaded

GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
ThomasParaiso2
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 

Recently uploaded (20)

GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...GridMate - End to end testing is a critical piece to ensure quality and avoid...
GridMate - End to end testing is a critical piece to ensure quality and avoid...
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 

Drupal8 render pipeline

  • 1. Drupal 8 render pipeline ~ Mahesh Salaria (@salaria) Kelltontech
  • 2. 2. renderResponse() Select page display variant Is a #type ‘page’ render array? hook_page_attachments() hook_page_(top|bottom)() Example: BlockPageVariant selected. render() main content Yes No Build page display variant The 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 the page title. render() entire HTML document Only accepts render arrays of #type ‘page’! Wrap in #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). render() main content Add InsertCommand new AjaxResponse() Get dialog options from Request Calculate title if not provided by main content Calculate title if not provided by main content render() main content Add OpenDialogCmd new AjaxResponse() The flow for all four formats supported in core in their respect is displayed next, but the explanations below only apply to the HtmlController! If an unsupported format was negotiated, a 406 response is generated. new HtmlResponse() 5. Calling the Controller 6. The ker nel . vi ew Event 7. The ker nel . r esponse Event Di al ogRender er Modal Render erHt ml Render er Aj axRender er No Response Initialize the corresponding main content renderer Is render array? Yes Main content renderer for request format exists? Yes Call : : r ender Response( ) Set Response on Event Generate 406 Response No Controller returns either: No 1. prepare() helper Calculate title if not provided by main content render() main content Add OpenModalDialogCmd new AjaxResponse() f or mat = ‘ aj ax’f or mat = ‘ modal ’ Mai nCont ent Vi ewSubscr i ber Response Response Response main content renderers f or mat = ‘ ht ml ’ f or mat = ‘ di al og’ DsCSystemController::systemAdminMenuBlockPage is called, it returns 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 event subscriber to turn it into a Response. MainContentViewSubscriber looks at the available main content renderer services. These are tagged with render.main_content_renderer. Contributed modules can additional renderers. Example: GET /admin. HTTP request 1. The ker nel . r equest event Determine route & controller HTTP response Negotiate format Request handling and rendering flow Example: /admin path → system.admin route That route has the following attributes: _content: 'DsCSystemController::systemAdminMenuBlockPage' _title: ‘Administration’ Explanation KernelEvents::REQUEST 2. Resolve the Controller 3. The ker nel . cont r ol l er event See http://symfony.com/doc/2.7/components/ http_kernel/introduction.html for more details — this shows the same steps. 4. Getting the Controller Arguments Yes i ndex. php 3. Call Response: : pr epar e( ) 2. Call Ht t pKer nel : : handl e( ) 1. Create Request from globals 4. Call Response: : send( ) 5. Call Ht t pKer nel : : t er mi nat e( ) Ht t pKer nel : : handl e( ) Symfony (HttpKernel) Drupal (Controller, MainContentViewSubscriber, main content renderers)Event handling KernelEvents::CONTROLLER Some 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 be ajax, dialog, modal, json, hal_json, and more. See: Symfony’s Request::setFormat(). _controller is set to 'DsCSystemController::systemAdminMenuBlockPage' KernelEvents::VIEW SELECT_PAGE_DISPLAY_VARIANT KernelEvents::TERMINATE Response Is Response? render array object with associated kernel.view event subscriber Colored overlaid arrows: showing the flow of the different types of Controller return values. Typical flow Note that HtmlResponse (as well as AjaxResponse) at this point still contains attachments: asset libraries, headers … but also placeholders. … Return placeholders unchanged Si ngl eFl ush ( cor e) Bi gPi pe ( cont r i b) … Transform placeholders to BigPipe placeholders placeholder strategies (HTML responses only) Is HTML response and has placeholders attached? : : pr ocessPl acehol der s( ) Set final pl acehol der s on Ht ml Response Yes Ht ml Res’ Pl acehol der St r at ’ Sub Placeholder strategies can transform standard Drupal placeholders (designed for non-deferred rendering) into other placeholders, which may be replaced with the final markup using any way possible. For example: BigPipe, ESI … ChainedPlaceholderStrategy looks at the available placeholder strategies. These are tagged with placeholder_strategy. Contributed modules can additional renderers. BigPipe is a contrib module during 8.0.x, will likely be in 8.1.x core. See https://www.drupal.org/project/big_pipe KernelEvents::RESPONSE No Ht ml Res’ At t achment sPr ocessor Render pl acehol der s Update HTML to load final assets, set attached headers on response … Process all other HtmlResponse attachments: asset libraries, HTML <head> elements, headers … BigPipe placeholders rendered at the end of::send(), after most is sent.
  • 3.
  • 4.
  • 5. HttpKernal Component • The HttpKernel component provides a structured process for converting a Request into a Response by making use of the EventDispatcher component. • Every HTTP web interaction begins with a request and ends with a response. Your job as a developer is to create PHP code that reads the request information (e.g. the URL) and creates and returns a response (e.g. an HTML page or JSON string).
  • 6.
  • 7. Routes • Routes whose controllers return a Response object bypass the pipeline. They rely directly on the Symfony render pipeline. • Route whose controllers return the "main content" as a render array automatically has the ability to be requested in multiple ways: it can be rendered in a certain format (HTML, JSON …) and/or in a certain decorated manner (e.g. with blocks around the main content).
  • 8. Events • The glue between Symfony and Drupal. • Triggered by HttpKernel::handle()
  • 9. Controllers • Business Logic to send response object or render array or an Object associated with Event Subscriber.
  • 10. Content Renderer • After the controller returned a render array, the VIEW will be triggered by the HttpKernel, because the controller result is not a Response, but a render array. • MainContentViewSubscriber checks whether the negotiated request format is supported. • All classes that implement MainContentRendererInterface • AjaxRenderer • DialogRenderer • HtmlRenderer • ModalRenderer
  • 11. Placeholder strategies (HTML responses only) • SingleFlush (Traditional Way) • BigPipe (https://youtu.be/JwzX0Qv6u3A) • During rendering, the personalized parts are turned into placeholders. • By default, Drupal 8 uses the Single Flush strategy (aka "traditional") for replacing the placeholders. i.e. we don't send a response until we've replaced all placeholders. • The BigPipe module introduces a new strategy, that allows us to flush the initial page first, and then stream the replacements for the placeholders. • This results in hugely improved front-end/perceived performance (watch the 40-second screencast above).
  • 12. BigPipe • BigPipe first breaks web pages into multiple chunks called pagelets and process into several stages: • Request parsing: web server parses and sanity checks the HTTP request. • Data fetching: web server fetches data from storage tier. • Markup generation: web server generates HTML markup for the response. • Network transport: the response is transferred from web server to browser. • CSS downloading: browser downloads CSS required by the page. • DOM tree construction and CSS styling: browser constructs DOM tree of the document, and then applies CSS rules on it. • JavaScript downloading: browser downloads JavaScript resources referenced by the page. • JavaScript execution: browser executes JavaScript code of the page. Source: https://www.drupal.org/project/big_pipe
  • 13. Refrences • https://www.drupal.org/developing/api/8/render/pipeline • https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Routing!routi ng.api.php/group/routing • http://wimleers.com/talk/drupal-8-render-pipeline • https://www.drupal.org/project/big_pipe • https://www.facebook.com/notes/facebook-engineering/bigpipe- pipelining-web-pages-for-high-performance/389414033919