mwltr/ext-magento2-mwltr-filesystem-filedriver

示例模块

1.2.3 2019-02-05 20:11 UTC

This package is auto-updated.

Last update: 2024-09-22 00:20:07 UTC


README

此模块替换了类 \Magento\Framework\Filesystem\Driver\File,以提供对 getRelativePath 方法的正确实现。

先决条件

只有当您计划在 Magento 根目录之外有 Magento 模块源时,才需要此模块。

实现

覆盖可以在 \Mwltr\FilesystemFileDriver\Filesystem\FileDriver 中找到。

相对路径计算的实际实现可以在 \Mwltr\FilesystemFileDriver\Helper\RelativePathHelper 中找到。

由于 DriverPool 定义在 \Magento\Framework\App\Bootstrap::createFilesystemDriverPool 中,因此不能通过 di.xml 定义来替换 \Magento\Framework\Filesystem\Driver\File

可以通过在 $_SERVER 中设置键为 Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DRIVERS 的数组字段,向 DriverPool 添加额外的参数。

此模块在 registration.php 中执行此操作,因为 registration.php 在整个 composer 自动加载过程中被包含。

$_SERVER[\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DRIVERS] = [
    'file' => \Mwltr\FilesystemFileDriver\Filesystem\FileDriver::class,
];