The new FileField doesn't seem to be compatible with a lazy adapter to switch storage backend.
Reference: https://github.com/thephpleague/flysystem-bundle/blob/3.x/docs/4-using-lazy-adapter-to-switch-at-runtime.md
Error:
The Flysystem storage "uploads.storage" is not configured. Make sure the service exists and implements "League\Flysystem\FilesystemOperator".
Reproduction:
flysystem.php:
'flysystem' => [
'storages' => [
'uploads.storage.bunny' => [
'adapter' => 'bunnycdn',
'options' => [
'client' => 'bunny_uploads_client',
'pull_zone' => '%env(BUNNY_PULL_ZONE)%',
],
],
'uploads.storage.local' => [
'adapter' => 'local',
'options' => [
'directory' => '%kernel.project_dir%/public/uploads',
],
'public_url_generator' => UploadsPublicUrlGenerator::class,
],
'uploads.storage' => [
'adapter' => 'lazy',
'options' => [
'source' => '%env(UPLOADS_SOURCE)%',
],
],
],
],
PostCrudController.php:
FileField::new('image')
->setFlysystemStorage('uploads.storage')
->setUploadDir('post/')
->setUploadedFileNamePattern('[slug]-[uuid].[extension]')
->setFileConstraints(new Image(maxSize: '1000k')),
Debug of "uploads.storage":
Information for Service "uploads.storage"
=========================================
----------------- ----------------------------------------------------------------------
Option Value
----------------- ----------------------------------------------------------------------
Service ID uploads.storage
Class League\Flysystem\FilesystemOperator
Tags flysystem.storage (storage: uploads.storage)
Public no
Synthetic no
Lazy no
Shared yes
Abstract no
Autowired no
Autoconfigured no
Factory Service flysystem.adapter.lazy.factory
Factory Method createStorage
Arguments env_317e6ce191d51965_UPLOADS_SOURCE_1fea29aec27751657d710ada745b0219
uploads.storage
Usages .League\Flysystem\FilesystemOperator $uploads.storage
League\Flysystem\FilesystemOperator $uploadsStorage
.League\Flysystem\FilesystemReader $uploads.storage
League\Flysystem\FilesystemReader $uploadsStorage
.League\Flysystem\FilesystemWriter $uploads.storage
League\Flysystem\FilesystemWriter $uploadsStorage
App\Service\FaviconService
App\Service\FileDownloaderService
.service_locator.KL9iKG.
.service_locator.4A03ICx
----------------- ----------------------------------------------------------------------
! [NOTE] The "uploads.storage" service or alias has been removed or inlined when the container was compiled.
Seems to come from:
|
if (null === $this->flysystemLocator || !$this->flysystemLocator->has($storageName)) { |
The new FileField doesn't seem to be compatible with a lazy adapter to switch storage backend.
Reference: https://github.com/thephpleague/flysystem-bundle/blob/3.x/docs/4-using-lazy-adapter-to-switch-at-runtime.md
Error:
The Flysystem storage "uploads.storage" is not configured. Make sure the service exists and implements "League\Flysystem\FilesystemOperator".Reproduction:
flysystem.php:
PostCrudController.php:
Debug of "uploads.storage":
Seems to come from:
EasyAdminBundle/src/Field/Configurator/ImageConfigurator.php
Line 175 in a3bbe5d