1,这个代码应该是页面的布局吧 能解释下什么意思吗?

这行代码在Zou_Demo/Block/Adminhtml/PhysicalStores.php里,
是后台PhysicalStores首页列表的布局,demoadmin_physicalstore_index.xml里调用的。
这个block代码主要实现2个功能:
- 加载grid列表,也就是调用
Block/Adminhtml/PhysicalStore/Grid.php - 添加了一个按钮('Add New PhysicalStore'),在右上角。
为什么这么说呢?
我们找到他继承(extends)的类,看这个类里写了些啥。Magento\Backend\Block\Widget\Grid\Container

可以看到,里面加了很多按钮,以及调用了grid.php。
它是通过$this->_blockGroup和$this->_controller来找到grid文件路径的。
str_replace(
'_',
'\\',
$this->_blockGroup
) . '\\Block\\' . str_replace(
' ',
'\\',
ucwords(str_replace('_', ' ', $this->_controller))
) . '\\Grid',
$this->_controller . '.grid'
我们PhysicalStores.php里定义的是
$this->_controller = 'adminhtml_physicalStore';
$this->_blockGroup = 'Zou_Demo';
所以他调用的grid文件路径为:
Zou\\Demo\\Block\\Adminhtml\\PhysicalStore\\Grid
我们再去看下这个grid.php里写了些啥?
都是些字段列表。
也就是这个页面的主要内容
好了,我们算是理清了。
同理,其他页面(比如编辑页面)也一样的逻辑。

本文深入解析Magento后台PhysicalStores页面布局代码。重点介绍了如何加载grid列表和添加'AddNewPhysicalStore'按钮,通过跟踪代码调用路径,理解Magento模块化设计原理。
2378

被折叠的 条评论
为什么被折叠?



