Skip to content

Fix the VFS adjustments in the latest Contao versions #374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2024
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/BulkyItem/BulkyItemStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
11 changes: 6 additions & 5 deletions tests/BulkyItem/BulkItemStorageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
},
Expand Down Expand Up @@ -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',
Expand All @@ -107,7 +108,7 @@ public function testRetrieve(): void
],
'class' => FileItem::class,
],
]))
])))
;

$vfs
Expand Down
7 changes: 4 additions & 3 deletions tests/BulkyItem/InMemoryDbafs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -17,7 +18,7 @@ class InMemoryDbafs implements DbafsInterface
private array $records = [];

/**
* @var array<string, array<mixed>>
* @var array<string, ExtraMetadata>
*/
private array $meta = [];

Expand All @@ -35,7 +36,7 @@ public function getRecord(string $path): FilesystemItem|null
null,
null,
null,
$this->meta[$path] ?? [],
$this->meta[$path] ?? null,
);
}

Expand All @@ -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;
}
Expand Down
Loading