SlideShare a Scribd company logo
Magento 2 Request
Flow
Magento 2 Architect
Eugene Tulika
Entry Point
Everything starts here
Entry Point
• Index.php or pub/index.php – web application
• Static.php – retrieve dynamically generated static files
• Get.php – retrieve media from database
• Cron.php – run commands by Cron
• bin/magento – command line tool
Entry Point
require __DIR__ . '/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication(MagentoFrameworkAppHttp::class);
$bootstrap->run($app);
/index.php
Bootstrap::createApplication
public function createApplication($type, $arguments = [])
{
$this->initObjectManager();
$application = $this->objectManager->create($type, $arguments);
// … type check
return $application;
}
/lib/internal/Magento/Framework/App/Bootstrap.php
Bootstrap::initObjectManager
• We hate init* methods. M1 was full of them
• Loads initial configuration (config.php, env.php, di.xml)
• Loads etc/di.xml files from all modules (global configuration)
• Last point where we have valid init* methods
Bootstrap::createApplication
public function createApplication($type, $arguments = [])
{
$this->initObjectManager();
$application = $this->objectManager->create($type, $arguments);
// … type check
return $application;
}
/lib/internal/Magento/Framework/App/Bootstrap.php
Entry Point
require __DIR__ . '/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$app = $bootstrap->createApplication(MagentoFrameworkAppHttp::class);
$bootstrap->run($app);
/index.php
ApplicationHttp
public function launch()
{
$frontName = $this->_request->getFrontName();
$areaCode = $this->areaList->getCodeByFrontName($frontName);
$this->state->setAreaCode($areaCode);
$this->objectManager->configure($this->_configLoader->load($areaCode));
$frontController = $this->objectManager->get(FrontControllerInterface::class);
$result = $frontController->dispatch($this->_request);
$result->renderResult($this->_response);
return $this->_response;
}
/lib/internal/Magento/Framework/App/Http.php
Application Areas
• Configuration scopes
• etc/<areaCode>/* in module folder
• Loaded on top of global configuration
• Admin, Frontend, Webapi_Rest, Webapi_Soap, Cron
Middleware
Going down the rabbit hole of the onion rings
Middleware
function (request) : response
• Function applied to request in order to generate response
• PSR-7
ApplicationHttp
public function launch()
{
$frontName = $this->_request->getFrontName();
$areaCode = $this->areaList->getCodeByFrontName($frontName);
$this->state->setAreaCode($areaCode);
$this->objectManager->configure($this->_configLoader->load($areaCode));
$frontController = $this->objectManager->get(FrontControllerInterface::class);
$result = $frontController->dispatch($this->_request);
$result->renderResult($this->_response);
return $this->_response;
}
/lib/internal/Magento/Framework/App/Http.php
Middleware
Dispatch
Authentication
CSRF Checks
Page Cache
HTTP Request
HTTP Response
Middleware
• Add your plugin on front controller if you want some logic executed
on all controllers
• Keep POST & GET in mind
Routing
Front Controller
public function dispatch(RequestInterface $request){
// …
foreach ($this->routerList as $router) {
$actionInstance = $router->match($request);
if ($actionInstance) {
$result = $actionInstance->execute();
break;
}
}
// …
return $result;
}
/lib/internal/Magento/Framework/App/FrontController.php
Routing
• Every area has own set of routers
• Important routers: standard for frontend & admin for admin
• Both configured in /etc/<areaCode>/routes.xml
• Cover 95% of cases (?)
Routing
<config>
<router id="standard">
<route id=”blog" frontName=”blog">
<module name=”My_Blog" />
</route>
</router>
</config>
/My/Module/etc/frontend/routes.xml
Actions
Front Controller
public function dispatch(RequestInterface $request){
// …
foreach ($this->routerList as $router) {
$actionInstance = $router->match($request);
if ($actionInstance) {
$result = $actionInstance->execute();
break;
}
}
// …
return $result;
}
/lib/internal/Magento/Framework/App/FrontController.php
Action Controllers
• Path handlers
• Single method execute
• By convention located in Controller folder of a module
• Different rules for GET and POST
• Request object should not be passed further. Extract arguments and
pass them separately.
Action Controllers
class View extends MagentoFrameworkAppActionAction
{
// constructor and properties
public function execute()
{
// do something
$result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$result->setPath('*/*/*');
// or
$result = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
return $result;
}
}
My/Module/Controller/Blog/Post/View.php
POST
POST Action Controllers
• Do not render pages. Layout is forbidden
• Only place for application workflow management (redirect,
messages, session)
• All business logic should be delegated to Service Contracts
• Request object should not be passed further. Extract arguments and
pass them separately.
POST Action Controller
class Save extends MagentoFrameworkAppActionAction
{
public function execute()
{
$post = $this->postFactory->create();
$post->setTitle($this->request->getParam('title'));
$post->setText($this->request->getParam('text'));
$post = $this->postRepository->save($post);
$result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$result->setPath(’blogs/post/view’, [’post_id' => $post->getId()]);
}
}
My/Module/Controller/Blog/Post/Save.php
Service Contracts
• Represent public API of a module
• Covered by Backwards Compatibility Policy
• Located Api folder of a module and marked with @api
• Expose procedural API (Service Interfaces) that communicate with
Data Transfer Objects (Data Interfaces)
Service Contracts
My/Module/Api/PostRepository.php
class PostRepository implements MyModuleApiPostRepositoryInterface
{
// ..
public function save(PostInterface $post)
{
$this->postResourceModel->save($post);
return $post;
}
}
Persistence
• Use Resource Models to Load/Save/Delete data
• Use Collections to load lists of data
• load, save, and delete on model are deprecated
POST Action Controller
class Save extends MagentoFrameworkAppActionAction
{
public function execute()
{
$post = $this->postFactory->create();
$post->setTitle($this->request->getParam('title'));
$post->setText($this->request->getParam('text'));
$post = $this->postRepository->save($post);
$result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$result->setPath(’blogs/post/view’, [’post_id' => $post->getId()]);
return $result;
}
}
My/Module/Controller/Blog/Post/Save.php
GET
GET Action Controller
class View extends MagentoFrameworkAppActionAction
{
// constructor and properties
public function execute()
{
$result = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
return $result;
}
}
/app/code/My/Module/Controller/Blog/Post/View.php
GET Action Controllers
• Do not reference blocks directly. They may not exist on the page
• Do not pre-load models and put them to registry. Load what you
need from blocks.
• DO NOTHING in Action Controllers that respond to GET requests
and render pages (only return PageResult)
Layout
/My/Module/view/frontend/layout/blog_post_view.xml
<page>
<body>
<referenceBlock name="container">
<block class="MyModuleBlockBlogPostView”
name=”blog.post.view”
template=”My_Module::blog/post/view.phtml"/>
</referenceBlock>
</body>
</page>
Blocks
/My/Module/view/frontend/templates/blog/post/view.phtml
<?php $post = $block->getBlogPost(); ?>
<article>
<header>
<h1><?php echo $block->escapeHtml($post->getTitle());?></h1>
<span class="date">
<?php echo $block->formatDate($post->getPublicationDate());?>
</span>
<a href="<?php echo $block->getBlogLink($post); ?>" class="blog">
<?php echo $block->escapeHtml(__('To Blog'));?>
</a>
</header>
<?php echo $post->getText(); ?>
</article>
Blocks
namespace MyModuleBlockBlogPost;
class View
{
public function getBlogPost()
{
return $this->postRepository->get($this->request->getParam('post_id'));
}
public function getBlogLink(Post $post)
{
$this->urlBuilder->getUrl('blogs', ['blog_id' => $post->getBlogId()]);
}
}
/My/Module/Block/Blog/Post/View.php
Blocks
/My/Module/view/frontend/templates/blog/post/view.phtml
<?php $post = $block->getBlogPost(); ?>
<article>
<header>
<h1><?php echo $block->escapeHtml($post->getTitle());?></h1>
<span class="date">
<?php echo $block->formatDate($post->getPublicationDate());?>
</span>
<a href="<?php echo $block->getBlogLink($post); ?>" class="blog">
<?php echo $block->escapeHtml(__('To Blog'));?>
</a>
</header>
<?php echo $post->getText(); ?>
</article>
Blocks
• Do not reference other sibling and parent blocks
• Do not perform state-modifications
• Retrieve data from public services
• Do not pass Request object further, extract arguments, and pass
them
Response
Action Results
namespace MagentoFrameworkController;
class ResultFactory
{
const TYPE_JSON = 'json';
const TYPE_RAW = 'raw';
const TYPE_REDIRECT = 'redirect';
const TYPE_FORWARD = 'forward';
const TYPE_LAYOUT = 'layout';
const TYPE_PAGE = 'page';
public function create($type, array $arguments = [])
{
// ...
return $resultInstance;
}
}
/lib/internal/Magento/Framework/Controller/ResultFactory.php
GET Action Controller
class View extends MagentoFrameworkAppActionAction
{
// constructor and properties
public function execute()
{
$result = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
return $result;
}
}
/app/code/My/Module/Controller/Blog/Post/View.php
ApplicationHttp
public function launch()
{
$frontName = $this->_request->getFrontName();
$areaCode = $this->areaList->getCodeByFrontName($frontName);
$this->state->setAreaCode($areaCode);
$this->objectManager->configure($this->_configLoader->load($areaCode));
$frontController = $this->objectManager->get(FrontControllerInterface::class);
$result = $frontController->dispatch($this->_request);
$result->renderResult($this->_response);
return $this->_response;
}
/lib/internal/Magento/Framework/App/Http.php
Q & A

More Related Content

What's hot

Nashvile Symfony Routes Presentation
Nashvile Symfony Routes PresentationNashvile Symfony Routes Presentation
Nashvile Symfony Routes Presentation
Brent Shaffer
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Intro to Ember.JS 2016
Intro to Ember.JS 2016Intro to Ember.JS 2016
Intro to Ember.JS 2016
Sandino Núñez
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Fabien Potencier
 
Jquery Fundamentals
Jquery FundamentalsJquery Fundamentals
Jquery Fundamentals
Rebecca Murphey
 
Matters of State
Matters of StateMatters of State
Matters of State
Kris Wallsmith
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
Javier Eguiluz
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
Jonathan Wage
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
RajthilakMCA
 
Codeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriCodeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate Uri
Abdul Malik Ikhsan
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkJeremy Kendall
 
Complex Architectures in Ember
Complex Architectures in EmberComplex Architectures in Ember
Complex Architectures in Ember
Matthew Beale
 
How routing works in angular js
How routing works in angular jsHow routing works in angular js
How routing works in angular js
codeandyou forums
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
Kris Wallsmith
 
Routing And Navigation
Routing And NavigationRouting And Navigation
Routing And Navigation
Eyal Vardi
 
Ember and containers
Ember and containersEmber and containers
Ember and containers
Matthew Beale
 
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonHow kris-writes-symfony-apps-london
How kris-writes-symfony-apps-london
Kris Wallsmith
 
Intro to Ember.js
Intro to Ember.jsIntro to Ember.js
Intro to Ember.js
Jay Phelps
 
sfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin BundlesfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin Bundleth0masr
 
An introduction to Ember.js
An introduction to Ember.jsAn introduction to Ember.js
An introduction to Ember.js
codeofficer
 

What's hot (20)

Nashvile Symfony Routes Presentation
Nashvile Symfony Routes PresentationNashvile Symfony Routes Presentation
Nashvile Symfony Routes Presentation
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Intro to Ember.JS 2016
Intro to Ember.JS 2016Intro to Ember.JS 2016
Intro to Ember.JS 2016
 
Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)Be RESTful (Symfony Camp 2008)
Be RESTful (Symfony Camp 2008)
 
Jquery Fundamentals
Jquery FundamentalsJquery Fundamentals
Jquery Fundamentals
 
Matters of State
Matters of StateMatters of State
Matters of State
 
Curso Symfony - Clase 3
Curso Symfony - Clase 3Curso Symfony - Clase 3
Curso Symfony - Clase 3
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
Building a dashboard using AngularJS
Building a dashboard using AngularJSBuilding a dashboard using AngularJS
Building a dashboard using AngularJS
 
Codeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate UriCodeigniter : Custom Routing - Manipulate Uri
Codeigniter : Custom Routing - Manipulate Uri
 
Keeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro Framework
 
Complex Architectures in Ember
Complex Architectures in EmberComplex Architectures in Ember
Complex Architectures in Ember
 
How routing works in angular js
How routing works in angular jsHow routing works in angular js
How routing works in angular js
 
How Kris Writes Symfony Apps
How Kris Writes Symfony AppsHow Kris Writes Symfony Apps
How Kris Writes Symfony Apps
 
Routing And Navigation
Routing And NavigationRouting And Navigation
Routing And Navigation
 
Ember and containers
Ember and containersEmber and containers
Ember and containers
 
How kris-writes-symfony-apps-london
How kris-writes-symfony-apps-londonHow kris-writes-symfony-apps-london
How kris-writes-symfony-apps-london
 
Intro to Ember.js
Intro to Ember.jsIntro to Ember.js
Intro to Ember.js
 
sfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin BundlesfDay Cologne - Sonata Admin Bundle
sfDay Cologne - Sonata Admin Bundle
 
An introduction to Ember.js
An introduction to Ember.jsAn introduction to Ember.js
An introduction to Ember.js
 

Similar to Magento Live Australia 2016: Request Flow

symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207patter
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento Extension
Hendy Irawan
 
Magento Performance Toolkit
Magento Performance ToolkitMagento Performance Toolkit
Magento Performance Toolkit
Sergii Shymko
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
Michelangelo van Dam
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
Andréia Bohner
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
Hisateru Tanaka
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
Javier Eguiluz
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
Lukas Smith
 
How to create a magento controller in magento extension
How to create a magento controller in magento extensionHow to create a magento controller in magento extension
How to create a magento controller in magento extensionHendy Irawan
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
Nate Abele
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
Lars Jankowfsky
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf Conference
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
Gordon Forsythe
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
Pavel Makhrinsky
 
Magento Dependency Injection
Magento Dependency InjectionMagento Dependency Injection
Magento Dependency InjectionAnton Kril
 
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UKKey Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
Max Pronko
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
Jonathan Wage
 
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentFirst Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven Development
Nuvole
 

Similar to Magento Live Australia 2016: Request Flow (20)

symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
How to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento ExtensionHow to Create A Magento Adminhtml Controller in Magento Extension
How to Create A Magento Adminhtml Controller in Magento Extension
 
Magento Performance Toolkit
Magento Performance ToolkitMagento Performance Toolkit
Magento Performance Toolkit
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8Unit testing after Zend Framework 1.8
Unit testing after Zend Framework 1.8
 
Silex Cheat Sheet
Silex Cheat SheetSilex Cheat Sheet
Silex Cheat Sheet
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
Symfony2 - from the trenches
Symfony2 - from the trenchesSymfony2 - from the trenches
Symfony2 - from the trenches
 
How to create a magento controller in magento extension
How to create a magento controller in magento extensionHow to create a magento controller in magento extension
How to create a magento controller in magento extension
 
Building Lithium Apps
Building Lithium AppsBuilding Lithium Apps
Building Lithium Apps
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
ZFConf 2010: Zend Framework & MVC, Model Implementation (Part 2, Dependency I...
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Drupal 8 migrate!
Drupal 8 migrate!Drupal 8 migrate!
Drupal 8 migrate!
 
Magento Dependency Injection
Magento Dependency InjectionMagento Dependency Injection
Magento Dependency Injection
 
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UKKey Insights into Development Design Patterns for Magento 2 - Magento Live UK
Key Insights into Development Design Patterns for Magento 2 - Magento Live UK
 
Symfony2 from the Trenches
Symfony2 from the TrenchesSymfony2 from the Trenches
Symfony2 from the Trenches
 
First Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven DevelopmentFirst Steps in Drupal Code Driven Development
First Steps in Drupal Code Driven Development
 

More from Vrann Tulika

Magento Web API Ecosystem. Imagine 2018
Magento Web API Ecosystem. Imagine 2018Magento Web API Ecosystem. Imagine 2018
Magento Web API Ecosystem. Imagine 2018
Vrann Tulika
 
Career of the Software Engineer in Modern Open-Source e-Commerce Company
Career of the Software Engineer in Modern Open-Source e-Commerce CompanyCareer of the Software Engineer in Modern Open-Source e-Commerce Company
Career of the Software Engineer in Modern Open-Source e-Commerce Company
Vrann Tulika
 
Magento Live Australia 2016 Facebook Chatbot for Magento
Magento Live Australia 2016 Facebook Chatbot for MagentoMagento Live Australia 2016 Facebook Chatbot for Magento
Magento Live Australia 2016 Facebook Chatbot for Magento
Vrann Tulika
 
Mage Titans USA 2016 Magento/Facebook/RabbitMQ
Mage Titans USA 2016 Magento/Facebook/RabbitMQMage Titans USA 2016 Magento/Facebook/RabbitMQ
Mage Titans USA 2016 Magento/Facebook/RabbitMQ
Vrann Tulika
 
Enterprise Patterns in Magento
Enterprise Patterns in MagentoEnterprise Patterns in Magento
Enterprise Patterns in Magento
Vrann Tulika
 
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
Vrann Tulika
 
PHP and Asynchronous Systems
PHP and Asynchronous SystemsPHP and Asynchronous Systems
PHP and Asynchronous Systems
Vrann Tulika
 

More from Vrann Tulika (7)

Magento Web API Ecosystem. Imagine 2018
Magento Web API Ecosystem. Imagine 2018Magento Web API Ecosystem. Imagine 2018
Magento Web API Ecosystem. Imagine 2018
 
Career of the Software Engineer in Modern Open-Source e-Commerce Company
Career of the Software Engineer in Modern Open-Source e-Commerce CompanyCareer of the Software Engineer in Modern Open-Source e-Commerce Company
Career of the Software Engineer in Modern Open-Source e-Commerce Company
 
Magento Live Australia 2016 Facebook Chatbot for Magento
Magento Live Australia 2016 Facebook Chatbot for MagentoMagento Live Australia 2016 Facebook Chatbot for Magento
Magento Live Australia 2016 Facebook Chatbot for Magento
 
Mage Titans USA 2016 Magento/Facebook/RabbitMQ
Mage Titans USA 2016 Magento/Facebook/RabbitMQMage Titans USA 2016 Magento/Facebook/RabbitMQ
Mage Titans USA 2016 Magento/Facebook/RabbitMQ
 
Enterprise Patterns in Magento
Enterprise Patterns in MagentoEnterprise Patterns in Magento
Enterprise Patterns in Magento
 
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
Розпаралелювання Програм на Фортрані з Використанням Техніки Переписувальних ...
 
PHP and Asynchronous Systems
PHP and Asynchronous SystemsPHP and Asynchronous Systems
PHP and Asynchronous Systems
 

Recently uploaded

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 

Recently uploaded (20)

GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 

Magento Live Australia 2016: Request Flow

  • 1.
  • 5. Entry Point • Index.php or pub/index.php – web application • Static.php – retrieve dynamically generated static files • Get.php – retrieve media from database • Cron.php – run commands by Cron • bin/magento – command line tool
  • 6. Entry Point require __DIR__ . '/app/bootstrap.php'; $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER); $app = $bootstrap->createApplication(MagentoFrameworkAppHttp::class); $bootstrap->run($app); /index.php
  • 7. Bootstrap::createApplication public function createApplication($type, $arguments = []) { $this->initObjectManager(); $application = $this->objectManager->create($type, $arguments); // … type check return $application; } /lib/internal/Magento/Framework/App/Bootstrap.php
  • 8. Bootstrap::initObjectManager • We hate init* methods. M1 was full of them • Loads initial configuration (config.php, env.php, di.xml) • Loads etc/di.xml files from all modules (global configuration) • Last point where we have valid init* methods
  • 9. Bootstrap::createApplication public function createApplication($type, $arguments = []) { $this->initObjectManager(); $application = $this->objectManager->create($type, $arguments); // … type check return $application; } /lib/internal/Magento/Framework/App/Bootstrap.php
  • 10. Entry Point require __DIR__ . '/app/bootstrap.php'; $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER); $app = $bootstrap->createApplication(MagentoFrameworkAppHttp::class); $bootstrap->run($app); /index.php
  • 11. ApplicationHttp public function launch() { $frontName = $this->_request->getFrontName(); $areaCode = $this->areaList->getCodeByFrontName($frontName); $this->state->setAreaCode($areaCode); $this->objectManager->configure($this->_configLoader->load($areaCode)); $frontController = $this->objectManager->get(FrontControllerInterface::class); $result = $frontController->dispatch($this->_request); $result->renderResult($this->_response); return $this->_response; } /lib/internal/Magento/Framework/App/Http.php
  • 12. Application Areas • Configuration scopes • etc/<areaCode>/* in module folder • Loaded on top of global configuration • Admin, Frontend, Webapi_Rest, Webapi_Soap, Cron
  • 13. Middleware Going down the rabbit hole of the onion rings
  • 14. Middleware function (request) : response • Function applied to request in order to generate response • PSR-7
  • 15. ApplicationHttp public function launch() { $frontName = $this->_request->getFrontName(); $areaCode = $this->areaList->getCodeByFrontName($frontName); $this->state->setAreaCode($areaCode); $this->objectManager->configure($this->_configLoader->load($areaCode)); $frontController = $this->objectManager->get(FrontControllerInterface::class); $result = $frontController->dispatch($this->_request); $result->renderResult($this->_response); return $this->_response; } /lib/internal/Magento/Framework/App/Http.php
  • 17. Middleware • Add your plugin on front controller if you want some logic executed on all controllers • Keep POST & GET in mind
  • 19. Front Controller public function dispatch(RequestInterface $request){ // … foreach ($this->routerList as $router) { $actionInstance = $router->match($request); if ($actionInstance) { $result = $actionInstance->execute(); break; } } // … return $result; } /lib/internal/Magento/Framework/App/FrontController.php
  • 20. Routing • Every area has own set of routers • Important routers: standard for frontend & admin for admin • Both configured in /etc/<areaCode>/routes.xml • Cover 95% of cases (?)
  • 21. Routing <config> <router id="standard"> <route id=”blog" frontName=”blog"> <module name=”My_Blog" /> </route> </router> </config> /My/Module/etc/frontend/routes.xml
  • 23. Front Controller public function dispatch(RequestInterface $request){ // … foreach ($this->routerList as $router) { $actionInstance = $router->match($request); if ($actionInstance) { $result = $actionInstance->execute(); break; } } // … return $result; } /lib/internal/Magento/Framework/App/FrontController.php
  • 24. Action Controllers • Path handlers • Single method execute • By convention located in Controller folder of a module • Different rules for GET and POST • Request object should not be passed further. Extract arguments and pass them separately.
  • 25. Action Controllers class View extends MagentoFrameworkAppActionAction { // constructor and properties public function execute() { // do something $result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $result->setPath('*/*/*'); // or $result = $this->resultFactory->create(ResultFactory::TYPE_PAGE); return $result; } } My/Module/Controller/Blog/Post/View.php
  • 26. POST
  • 27. POST Action Controllers • Do not render pages. Layout is forbidden • Only place for application workflow management (redirect, messages, session) • All business logic should be delegated to Service Contracts • Request object should not be passed further. Extract arguments and pass them separately.
  • 28. POST Action Controller class Save extends MagentoFrameworkAppActionAction { public function execute() { $post = $this->postFactory->create(); $post->setTitle($this->request->getParam('title')); $post->setText($this->request->getParam('text')); $post = $this->postRepository->save($post); $result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $result->setPath(’blogs/post/view’, [’post_id' => $post->getId()]); } } My/Module/Controller/Blog/Post/Save.php
  • 29. Service Contracts • Represent public API of a module • Covered by Backwards Compatibility Policy • Located Api folder of a module and marked with @api • Expose procedural API (Service Interfaces) that communicate with Data Transfer Objects (Data Interfaces)
  • 30. Service Contracts My/Module/Api/PostRepository.php class PostRepository implements MyModuleApiPostRepositoryInterface { // .. public function save(PostInterface $post) { $this->postResourceModel->save($post); return $post; } }
  • 31. Persistence • Use Resource Models to Load/Save/Delete data • Use Collections to load lists of data • load, save, and delete on model are deprecated
  • 32. POST Action Controller class Save extends MagentoFrameworkAppActionAction { public function execute() { $post = $this->postFactory->create(); $post->setTitle($this->request->getParam('title')); $post->setText($this->request->getParam('text')); $post = $this->postRepository->save($post); $result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $result->setPath(’blogs/post/view’, [’post_id' => $post->getId()]); return $result; } } My/Module/Controller/Blog/Post/Save.php
  • 33. GET
  • 34. GET Action Controller class View extends MagentoFrameworkAppActionAction { // constructor and properties public function execute() { $result = $this->resultFactory->create(ResultFactory::TYPE_PAGE); return $result; } } /app/code/My/Module/Controller/Blog/Post/View.php
  • 35. GET Action Controllers • Do not reference blocks directly. They may not exist on the page • Do not pre-load models and put them to registry. Load what you need from blocks. • DO NOTHING in Action Controllers that respond to GET requests and render pages (only return PageResult)
  • 37. Blocks /My/Module/view/frontend/templates/blog/post/view.phtml <?php $post = $block->getBlogPost(); ?> <article> <header> <h1><?php echo $block->escapeHtml($post->getTitle());?></h1> <span class="date"> <?php echo $block->formatDate($post->getPublicationDate());?> </span> <a href="<?php echo $block->getBlogLink($post); ?>" class="blog"> <?php echo $block->escapeHtml(__('To Blog'));?> </a> </header> <?php echo $post->getText(); ?> </article>
  • 38. Blocks namespace MyModuleBlockBlogPost; class View { public function getBlogPost() { return $this->postRepository->get($this->request->getParam('post_id')); } public function getBlogLink(Post $post) { $this->urlBuilder->getUrl('blogs', ['blog_id' => $post->getBlogId()]); } } /My/Module/Block/Blog/Post/View.php
  • 39. Blocks /My/Module/view/frontend/templates/blog/post/view.phtml <?php $post = $block->getBlogPost(); ?> <article> <header> <h1><?php echo $block->escapeHtml($post->getTitle());?></h1> <span class="date"> <?php echo $block->formatDate($post->getPublicationDate());?> </span> <a href="<?php echo $block->getBlogLink($post); ?>" class="blog"> <?php echo $block->escapeHtml(__('To Blog'));?> </a> </header> <?php echo $post->getText(); ?> </article>
  • 40. Blocks • Do not reference other sibling and parent blocks • Do not perform state-modifications • Retrieve data from public services • Do not pass Request object further, extract arguments, and pass them
  • 42. Action Results namespace MagentoFrameworkController; class ResultFactory { const TYPE_JSON = 'json'; const TYPE_RAW = 'raw'; const TYPE_REDIRECT = 'redirect'; const TYPE_FORWARD = 'forward'; const TYPE_LAYOUT = 'layout'; const TYPE_PAGE = 'page'; public function create($type, array $arguments = []) { // ... return $resultInstance; } } /lib/internal/Magento/Framework/Controller/ResultFactory.php
  • 43. GET Action Controller class View extends MagentoFrameworkAppActionAction { // constructor and properties public function execute() { $result = $this->resultFactory->create(ResultFactory::TYPE_PAGE); return $result; } } /app/code/My/Module/Controller/Blog/Post/View.php
  • 44. ApplicationHttp public function launch() { $frontName = $this->_request->getFrontName(); $areaCode = $this->areaList->getCodeByFrontName($frontName); $this->state->setAreaCode($areaCode); $this->objectManager->configure($this->_configLoader->load($areaCode)); $frontController = $this->objectManager->get(FrontControllerInterface::class); $result = $frontController->dispatch($this->_request); $result->renderResult($this->_response); return $this->_response; } /lib/internal/Magento/Framework/App/Http.php
  • 45. Q & A

Editor's Notes

  1. Request flow process governs the application
  2. Changed to bin/mageno Magento has multiple entrypoints Depends on the client
  3. Creates the instance of application
  4. What is type check? Initializes Object Manager
  5. Init is not a good pattern, it encourages temporal coupling What does it mean “Last point where we have valid init* methods?”
  6. Creates application object using object manager DI is already initialized; all the plugins and preferences will be picked up
  7. Runs application
  8. Load areas
  9. Area defines scopes of configuration Allows to configure frontend and backend differently Area distinguishes different parts of application
  10. Anything special about this screenshot? - In order to separate the concerns, all custom logic applicable to all controllers should be added as plugins to the front controller - This follows AOP approach - Some logic might be applicable to POST only, like CSRF
  11. Front controller invokes routing logic
  12. Custom routes can be created Most likely standard ones will only be needed Admin routes takes into account “admin” part of the url
  13. Configuration of the route which tells that blog part of url will invoke action controllers in My_Blog module
  14. Request routing searches for action controller based on the request url Once request is routed it means that action controller is found Front controller invokes action controller
  15. What is “Path handlers”?
  16. Action Controller creates Response based on Request We will talk more on types of responses later
  17. This is ideal GET action controller
  18. Layout defines which blocks are on the page requested by GET Block are referenced by Layout object based on this declaration
  19. Template is the place where most of the request processing logic happens on GET
  20. Block should have just methods needed by the template to render Block should not have generic methods to render itself. It should be injected with the helper classes instead We are moving to direction where block is a generic class and all the functions are injected as dependencies Block should not implement this logic by itself, it should delegate calls to more appropriate classes
  21. Template renders information which block provides
  22. Result is representation of HTTP response Different Results can be created by Action controller
  23. Action controller returns result
  24. Application get result from the middleware and renders it