Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/EventSubscriber/ContentEntryUploadSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,7 +26,7 @@
final class ContentEntryUploadSubscriber
{
public function __construct(
private readonly StorageInterface $storage,
private readonly StorageResolver $storage,
private readonly HashingNamingStrategy $strategy,
) {
}
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 5 additions & 4 deletions src/Form/Type/DynamicEntryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +27,7 @@ class DynamicEntryType extends AbstractType
{
use CollectionEntrySortTypeTrait;

public function __construct(private readonly StorageInterface $storage)
public function __construct(private readonly StorageResolver $storage)
{
}

Expand Down Expand Up @@ -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;
Expand Down