From 354153ffeea06b49f5087e8f3bdd6ad2e7be10d2 Mon Sep 17 00:00:00 2001 From: dev Date: Fri, 27 Feb 2026 19:58:31 +0300 Subject: [PATCH] [fix] use StorageResolver instead of StorageInterface in content system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit StorageInterface is not registered for autowiring in file-bundle — Storage/ directory is excluded and no alias is provided. StorageResolver is explicitly registered and provides access to the default storage via get('default'). Co-Authored-By: Claude Sonnet 4.6 --- src/EventSubscriber/ContentEntryUploadSubscriber.php | 9 +++++---- src/Form/Type/DynamicEntryType.php | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/EventSubscriber/ContentEntryUploadSubscriber.php b/src/EventSubscriber/ContentEntryUploadSubscriber.php index c45140f..5dd790e 100644 --- a/src/EventSubscriber/ContentEntryUploadSubscriber.php +++ b/src/EventSubscriber/ContentEntryUploadSubscriber.php @@ -14,7 +14,7 @@ use ChamberOrchestra\CmsBundle\Entity\ContentEntry; use ChamberOrchestra\FileBundle\Model\File as FileModel; use ChamberOrchestra\FileBundle\NamingStrategy\HashingNamingStrategy; -use ChamberOrchestra\FileBundle\Storage\StorageInterface; +use ChamberOrchestra\FileBundle\Storage\StorageResolver; use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener; use Doctrine\ORM\Event\PrePersistEventArgs; use Doctrine\ORM\Event\PreUpdateEventArgs; @@ -26,7 +26,7 @@ final class ContentEntryUploadSubscriber { public function __construct( - private readonly StorageInterface $storage, + private readonly StorageResolver $storage, private readonly HashingNamingStrategy $strategy, ) { } @@ -121,8 +121,9 @@ private function processArray(array &$data, bool &$changed): void { foreach ($data as $key => $value) { if ($value instanceof UploadedFile) { - $data[$key] = $this->storage->resolveUri( - $this->storage->upload($value, $this->strategy), + $storage = $this->storage->get('default'); + $data[$key] = $storage->resolveUri( + $storage->upload($value, $this->strategy), ); $changed = true; } elseif ($value instanceof FileModel) { diff --git a/src/Form/Type/DynamicEntryType.php b/src/Form/Type/DynamicEntryType.php index 5dd3f2f..98b1c99 100644 --- a/src/Form/Type/DynamicEntryType.php +++ b/src/Form/Type/DynamicEntryType.php @@ -13,7 +13,7 @@ use ChamberOrchestra\CmsBundle\Form\Dto\ContentEntryDto; use ChamberOrchestra\FileBundle\Model\File as FileModel; -use ChamberOrchestra\FileBundle\Storage\StorageInterface; +use ChamberOrchestra\FileBundle\Storage\StorageResolver; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; @@ -27,7 +27,7 @@ class DynamicEntryType extends AbstractType { use CollectionEntrySortTypeTrait; - public function __construct(private readonly StorageInterface $storage) + public function __construct(private readonly StorageResolver $storage) { } @@ -157,9 +157,10 @@ public function buildForm(FormBuilderInterface $builder, array $options): void private function uriToFsPath(string $uri): string { - $prefix = $this->storage->resolveUri(''); + $storage = $this->storage->get('default'); + $prefix = $storage->resolveUri(''); if (null !== $prefix && \str_starts_with($uri, $prefix)) { - return $this->storage->resolvePath(\substr($uri, \strlen($prefix))); + return $storage->resolvePath(\substr($uri, \strlen($prefix))); } return $uri;