首页 文章

symfony 4 - flysystem autowire

提问于
浏览
0

你可以帮我这个吗?

无法自动装配服务“App \ Estimate \ DocumentManager”:方法“__construct()”的参数“$ flysystem”引用类“League \ Flysystem \ Filesystem”但不存在此类服务 . 您应该将此类别名为现有的“oneup_flysystem.estimateDocumentsFilesystem_filesystem”服务 .

我的配置文件:

parameters:
    flysystem.local.estimate_documents.path: '%kernel.root_dir%/../public/uploads/estimate/documents'

services:
    app.estimate.document_manager:
        class: App\Estimate\DocumentManager
        lazy: true
        public: true
        arguments: ['@doctrine.orm.entity_manager', '@estimateDocumentsFilesystem', '@monolog.logger']

oneup_flysystem:
    filesystems:
        estimateDocumentsFilesystem:
            adapter: estimateDocumentsAdapter
            visibility: public
            alias: "estimate_documents_filesystem"

    adapters:
        estimateDocumentsAdapter:
            local:
                directory: "%flysystem.local.estimate_documents.path%"

class DocumentManager
{

    /**
     * @var EntityManager
     */
    private $manager;

    /**
     * @var Filesystem
     */
    private $flysystem;

    /**
     * @var Logger
     */
    private $logger;

    /**
     * DocumentManager constructor.
     *
     * @param EntityManagerInterface $manager
     * @param Filesystem $flysystem
     * @param Logger $logger
     */
    public function __construct(
        EntityManagerInterface $manager,
        Filesystem $flysystem,
        Logger $logger
    )
    {
        $this->manager = $manager;
        $this->flysystem = $flysystem;
        $this->logger = $logger;
    }
}

非常感谢 . 我无法理解问题出在哪里 .

//编辑:

如果我添加这个如果我在配置中添加此项

services:
League\Flysystem\FilesystemInterface: '@estimate_documents_filesystem'

它只适用于一个文件系统f ...是错误的吗?

最好的问候吉米

1 回答

  • 1

    需要关闭自动装配和自动配置 . 添加这个:

    autoconfigure:false
    autowire:false
    

    完整配置:

    App\Estimate\Document\DocumentManager:
        autoconfigure: false
        autowire: false
        arguments: ['@doctrine.orm.entity_manager', '@estimate_documents_filesystem', '@monolog.logger']
    
    App\User\DocumentManager:
        autoconfigure: false
        autowire: false
        arguments: ['@doctrine.orm.entity_manager', '@user_avatars_filesystem', '@monolog.logger']
    

相关问题