3

Given two action controllers

  1. One extending \Magento\Framework\App\Action\Action
  2. One implementing \Magento\Framework\App\ActionInterface

Both simply return the value of \Magento\Framework\View\Result\PageFactory::create()

Both have a layout XML file matching the handles for the respective requests. Both of the files extend the 1columns layout.

For the first action controller extending Action the result is (as expected) a rendered Magento page with an empty content area.

But for the second controller implementing the interface a completely white page is displayed (technically only the root template is rendered).

The only difference I was able to see was that the second controller does not dispatch the events triggered in Action::dispatch(). But even after also dispatching the same events there was no difference in the rendered page.

Debugging further I noticed in \Magento\Framework\View\File\Collector\Base::getFiles() the theme was not properly initialized.

$area = $theme->getData('area'); returned null. Replacing that with $area = $theme->getArea() fixed that. Now the paths to the base view files are correct, but no theme files are loaded.

In \Magento\Framework\View\File\Collector\ThemeModular::getFiles() the line $themePath = $theme->getFullPath(); returns null.

Now, finally, my question is: where is the theme initialized? Further questions are why does that happen for the first action controller and not for the second?

  • Can you please clarify what are your dependencies specified via constructor? – Ivan Chepurnyi Mar 10 '16 at 8:54
5

I'd go as far as calling it a bug/incomplete implementation in Magento Core.

Magento\Framework\App\Action\Action has 6 plugins defined, a couple that look more interesting than others are Magento\Store\App\Action\Plugin\Context and Magento\Framework\App\Action\Plugin\Design

\Magento\Framework\App\ActionInterface has 0 plugins defined but I think the above plugins should have been added on the interface level. Unfortunately the interface itself only includes the execute method but most of the plugins work with the dispatch method.

| improve this answer | |

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.