1

I have Magento 2 with sample data and I came across this file

generation\Magento\Framework\View\Result\Layout\interceptor.php.

The Interceptor file is generated only if any module wants to plugin (before/after/around) any method in given class . for example, this method renderResult() does not have any plugin like beforeRenderResult/aroundRenderResult . then Why interceptor file was generated ? Are there any other scenarios where interception file can be generated ?

public function renderResult(\Magento\Framework\App\ResponseInterface $response)
{
    $pluginInfo = $this->pluginList->getNext($this->subjectType, 'renderResult');
    if (!$pluginInfo) {
        return parent::renderResult($response);
    } else {
        return $this->___callPlugins('renderResult', func_get_args(), $pluginInfo);
    }
} 
  • Don't forget that you can mark answers as accepted if they helped you ;) – Fabian Schmengler Apr 12 '16 at 19:38
3

Plugins are inherited. Magento\Framework\View\Result\Layout implements Magento\Framework\Controller\ResultInterface and this interface have plugins

<type name="Magento\Framework\Controller\ResultInterface">
    <plugin name="result-builtin-cache" type="Magento\PageCache\Model\Controller\Result\BuiltinPlugin"/>
    <plugin name="result-varnish-cache" type="Magento\PageCache\Model\Controller\Result\VarnishPlugin"/>
</type>

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.