I am learning magento 2.1 request flow.

I am stuck here:

$frontController = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface');
$result = $frontController->dispatch($this->_request);

I can't find dispatch function.

if I go to vendor/magento/framework/App/FrontController.php dispatch function and add die('ok') it doesn't get executed:

public function dispatch(RequestInterface $request)
    die("ok"); /* doesn't get executed */  

if I add:


to vendor/magento/framework/App/Http.php launch:

$frontController = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface');
$result = $frontController->dispatch($this->_request);

I get Magento\Framework\App\FrontController\Interceptor

but where is Magento\Framework\App\FrontController\Interceptor ?

there is no vendor/magento/framework/App/FrontController/Interceptor.php

obviously I am missing something - would appreciate an insight from an expert.


The classes that end with Interceptor (and Proxy and sometimes Factory) are autogenerated and found in var/generation following the same file path as usual.
These interceptors are generated automatically by Magento and used in some places instead of the real classes in order to be able to have plugins attached to it.
So you can extend or replace the functionality of public methods without the need to rewrite the class

You can find out more about how the plugins / interceptors work from the official documentation.
Just keep in mind that every change you make to these interceptor classes will be useless because they will be lost when the class is generated again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.