KnpLabs / KnpGaufretteBundle

Easily use Gaufrette in your Symfony projects.
http://knplabs.com
MIT License
716 stars 157 forks source link

Support Autowiring Filesystems #276

Open mvhirsch opened 1 year ago

mvhirsch commented 1 year ago

I'm trying to use Symfony's autowiring like this:

# knp_gaufrette.yaml
knp_gaufrette:
    filesystems:
        import: { adapter: import }
<?php

namespace App\Command;

use Gaufrette\FilesystemInterface;

final class MyCommand
{
    public function __construct(FilesytemInterface $importFilesystem) 
    {

    }
}

But it results in an error:

Cannot autowire service "App\Command\MyCommand": argument "$importFilesystem" of method "__construct()" references interface "Gaufrette\FilesystemInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "sonata.media.filesystem.s3", "gaufrette.import_filesytem", ...

Seems like there is no support for this like MonologBundle does?

Would it be possible to add aliases so this will be possible? I'm using 0.7.1 (as I cannot upgrade to PHP 8 by now). Could this change be backported to 0.7.x, too?