Feature request from dbsdsun, posted on GitHub May 18, 2015
Problem:
- One block may template files. The Module Name is used to determine the template file location.
- MoudleB_BlockB can extend ModuleA_BlockA by specification in di.xml as following:
In this case, the MoudleB_BlockB should use ModuleA as its module name, rather than MoudleB.
Solution:
Set target module name when generating a block as follwing. And this is last chance to set target module name.
in file lib/internal/Magento/Framework/View/Layout/Generator/Block.php, after line 157, add one line
line155. $block = $this->createBlock($className, $elementName, [
line156. 'data' => $this->evaluateArguments($data['arguments'])
line157. ]);
new line. $block->setModuleName($block->extractModuleName($className));
line158. if (!empty($attributes['template'])) {
line159. $block->setTemplate($attributes['template']);
line160. }