Trình tự trong module.xmlcó tác động đến app/etc/config.php. Tệp này được cập nhật khi bạn chạy bin/magento module:enable Vendor_ModuleNamevì vậy nếu bạn đã thêm / thay đổi trình tự, tôi khuyên bạn nên tắt mô-đun của mình và sau đó bật lại. Đang cập nhật của bạn module.xmltập tin và xoá bộ nhớ cache của bạn không đủ ở đây, bạn sẽ cần phải làm đầy đủ disablelại enablechu kỳ để có được Magento thấy các thay đổi chuỗi quá trình phát triển.
Thứ tự sắp xếp các mô-đun trong config.phptệp sau đó được sử dụng cho tất cả các tệp cấu hình khác đang tải theo nhận xét của Anton tại đây.
Các vị trí mã trong bình luận đó là một chút lỗi thời. Đây là mã để sắp xếp thứ tự https://github.com/magento/magento2/blob/2.0.2/lib/iternal/Magento/Framework/Module/ModuleList/Loader.php#L131
Cập nhật 2:
ứng dụng / etc / di.xml
<type name="Magento\Framework\View\Model\Layout\Merge">
<arguments>
<argument name="fileSource" xsi:type="object">Magento\Framework\View\Layout\File\Collector\Aggregated\Proxy</argument>
<argument name="pageLayoutFileSource" xsi:type="object">pageLayoutFileCollectorAggregated</argument>
<argument name="cache" xsi:type="object">Magento\Framework\App\Cache\Type\Layout</argument>
</arguments>
</type>
tham chiếu trình thu thập tệp bố cục trang trong cùng một di.xml
<virtualType name="pageLayoutFileCollectorAggregated" type="Magento\Framework\View\Layout\File\Collector\Aggregated">
<arguments>
<argument name="baseFiles" xsi:type="object">pageLayoutFileSourceBaseSorted</argument>
<argument name="themeFiles" xsi:type="object">pageLayoutFileSourceThemeSorted</argument>
<argument name="overrideBaseFiles" xsi:type="object">pageLayoutFileSourceOverrideBaseSorted</argument>
<argument name="overrideThemeFiles" xsi:type="object">pageLayoutFileSourceOverrideThemeSorted</argument>
</arguments>
</virtualType>
cái mà chúng ta quan tâm pageLayoutFileSourceBaseSortedvẫn nằm trong cùng một di.xml
<virtualType name="pageLayoutFileSourceBaseSorted" type="Magento\Framework\View\File\Collector\Decorator\ModuleDependency">
<arguments>
<argument name="subject" xsi:type="object">pageLayoutFileSourceBaseFiltered</argument>
</arguments>
</virtualType>
Magento\Framework\View\File\Collector\Decorator\ModuleDependency sắp xếp như sau
protected function getModulePriority($moduleName)
{
if ($this->orderedModules === null) {
$this->orderedModules = $this->moduleList->getNames();
}
$result = array_search($moduleName, $this->orderedModules);
// Assume unknown modules have the same priority, distinctive from known modules
if ($result === false) {
return -1;
}
return $result;
}
nơi moduleListdựa vào Magento\Framework\Module\ModuleListđó lần lượt sử dụng Trình tải được đề cập ở trên.