diff --git a/composer.json b/composer.json index 8b30cef..93d1acf 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "php": "^8.1", "composer-plugin-api": "^2.0", "codefog/contao-haste": "^5.2", - "contao/core-bundle": "^4.13.17 || ^5.1.1", + "contao/core-bundle": "^4.13.50 || ^5.3.14 || ^5.4.4", "doctrine/dbal": "^3.4", "doctrine/orm": "^2.19", "knplabs/knp-menu": "^3.1", diff --git a/src/BulkyItem/BulkyItemStorage.php b/src/BulkyItem/BulkyItemStorage.php index b18f488..f9401b5 100644 --- a/src/BulkyItem/BulkyItemStorage.php +++ b/src/BulkyItem/BulkyItemStorage.php @@ -4,6 +4,7 @@ namespace Terminal42\NotificationCenterBundle\BulkyItem; +use Contao\CoreBundle\Filesystem\ExtraMetadata; use Contao\CoreBundle\Filesystem\VirtualFilesystemException; use Contao\CoreBundle\Filesystem\VirtualFilesystemInterface; use Symfony\Component\Uid\Uuid; @@ -32,7 +33,7 @@ public function store(BulkyItemInterface $item): string 'class' => $item::class, ]; - $this->filesystem->setExtraMetadata($voucher, ['storage_meta' => $meta]); + $this->filesystem->setExtraMetadata($voucher, new ExtraMetadata(['storage_meta' => $meta])); return $voucher; } diff --git a/tests/BulkyItem/BulkItemStorageTest.php b/tests/BulkyItem/BulkItemStorageTest.php index 793ed74..131314d 100644 --- a/tests/BulkyItem/BulkItemStorageTest.php +++ b/tests/BulkyItem/BulkItemStorageTest.php @@ -4,6 +4,7 @@ namespace Terminal42\NotificationCenterBundle\Test\BulkyItem; +use Contao\CoreBundle\Filesystem\ExtraMetadata; use Contao\CoreBundle\Filesystem\FilesystemItem; use Contao\CoreBundle\Filesystem\FilesystemItemIterator; use Contao\CoreBundle\Filesystem\VirtualFilesystemInterface; @@ -56,14 +57,14 @@ function (string $voucher) { }, ), $this->callback( - function (array $meta) { + function (ExtraMetadata $meta) { $this->assertArrayHasKey('storage_meta', $meta); $this->assertSame([ 'name' => 'foobar.png', 'type' => 'image/png', 'size' => 100, - ], $meta['storage_meta']['item']); - $this->assertSame(FileItem::class, $meta['storage_meta']['class']); + ], $meta->get('storage_meta')['item']); + $this->assertSame(FileItem::class, $meta->get('storage_meta')['class']); return true; }, @@ -98,7 +99,7 @@ public function testRetrieve(): void ->expects($this->once()) ->method('get') ->with('a10aed4d-abe1-498f-adfc-b2e54fbbcbde') - ->willReturn(new FilesystemItem(true, 'foobar', null, null, null, [ + ->willReturn(new FilesystemItem(true, 'foobar', null, null, null, new ExtraMetadata([ 'storage_meta' => [ 'item' => [ 'name' => 'foobar.png', @@ -107,7 +108,7 @@ public function testRetrieve(): void ], 'class' => FileItem::class, ], - ])) + ]))) ; $vfs diff --git a/tests/BulkyItem/InMemoryDbafs.php b/tests/BulkyItem/InMemoryDbafs.php index 3c3568a..795e831 100644 --- a/tests/BulkyItem/InMemoryDbafs.php +++ b/tests/BulkyItem/InMemoryDbafs.php @@ -6,6 +6,7 @@ use Contao\CoreBundle\Filesystem\Dbafs\ChangeSet\ChangeSet; use Contao\CoreBundle\Filesystem\Dbafs\DbafsInterface; +use Contao\CoreBundle\Filesystem\ExtraMetadata; use Contao\CoreBundle\Filesystem\FilesystemItem; use Symfony\Component\Uid\Uuid; @@ -17,7 +18,7 @@ class InMemoryDbafs implements DbafsInterface private array $records = []; /** - * @var array> + * @var array */ private array $meta = []; @@ -35,7 +36,7 @@ public function getRecord(string $path): FilesystemItem|null null, null, null, - $this->meta[$path] ?? [], + $this->meta[$path] ?? null, ); } @@ -47,7 +48,7 @@ public function getRecords(string $path, bool $deep = false): iterable throw new \RuntimeException('Not implemented'); } - public function setExtraMetadata(string $path, array $metadata): void + public function setExtraMetadata(string $path, ExtraMetadata $metadata): void { $this->meta[$path] = $metadata; }