Skip to content

Commit 5a5ea4e

Browse files
committed
Fix allowedComponents IRI generation to use GetCollection operation
getIriFromResource(NavigationLink::class) without an operation tries to generate an item IRI and fails with missing {id}. Pass GetCollection so the converter produces the collection IRI, matching AbstractPageFixture.
1 parent aa6f6ee commit 5a5ea4e

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/Fixture/CwaFixtureBuilder.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace Silverback\ApiComponentsBundle\Fixture;
1313

14+
use ApiPlatform\Metadata\GetCollection;
1415
use ApiPlatform\Metadata\IriConverterInterface;
16+
use ApiPlatform\Metadata\UrlGeneratorInterface;
1517
use Doctrine\Persistence\ObjectManager;
1618
use Silverback\ApiComponentsBundle\Entity\Core\AbstractPage;
1719
use Silverback\ApiComponentsBundle\Entity\Core\AbstractPageData;
@@ -316,7 +318,11 @@ private function phaseTwo(): void
316318

317319
foreach ($groupBuilder->getAllowedClasses() as $class) {
318320
$componentGroup->addAllowedComponent(
319-
$this->iriConverter->getIriFromResource($class)
321+
$this->iriConverter->getIriFromResource(
322+
$class,
323+
UrlGeneratorInterface::ABS_PATH,
324+
(new GetCollection())->withClass($class)
325+
)
320326
);
321327
}
322328

tests/Fixture/CwaFixtureBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function test_layout_group_creates_component_group_with_correct_propertie
170170
$em = $this->collectingEm($persisted);
171171

172172
$iriConverter = $this->createStub(IriConverterInterface::class);
173-
$iriConverter->method('getIriFromResource')->willReturn('/_/some_components');
173+
$iriConverter->method('getIriFromResource')->willReturn('/_/some_components'); // any call returns the stub IRI
174174

175175
$builder = $this->makeBuilder($em, iriConverter: $iriConverter);
176176
$builder->layout('main', 'CwaLayoutPrimary')->group('nav', allow: [\stdClass::class]);

0 commit comments

Comments
 (0)