Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
Can you please clarify what are your dependencies specified via constructor? – Ivan Chepurnyi Mar 10 at 8:54
up vote 4 down vote accepted

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.

share|improve this answer
    
Good, thank you @kristof-at-fooman! – Vinai Mar 10 at 9:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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