Skip to content

Commit 5609707

Browse files
authored
Merge pull request #15 from netgen-layouts/fix-mapping-layout-to-specific-resource
Fix mapping layout to a specific resource
2 parents 7a622f2 + 4bccda3 commit 5609707

File tree

8 files changed

+12
-6
lines changed

8 files changed

+12
-6
lines changed

Diff for: bundle/EventListener/Shop/ProductIndexListener.php

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
use Symfony\Component\HttpFoundation\Request;
1414
use Symfony\Component\HttpFoundation\RequestStack;
1515

16+
/**
17+
* @deprecated since 1.4.6 together with nglayouts_sylius_taxon attribute, use nglayouts_sylius_resource (set by ResourceShowListener) instead
18+
*/
1619
final class ProductIndexListener implements EventSubscriberInterface
1720
{
1821
/**

Diff for: bundle/EventListener/Shop/ProductShowListener.php

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
use Symfony\Component\HttpFoundation\Request;
1212
use Symfony\Component\HttpFoundation\RequestStack;
1313

14+
/**
15+
* @deprecated since 1.4.6 together with nglayouts_sylius_product attribute, use nglayouts_sylius_resource (set by ResourceShowListener) instead
16+
*/
1417
final class ProductShowListener implements EventSubscriberInterface
1518
{
1619
public function __construct(private RequestStack $requestStack, private Context $context) {}

Diff for: lib/Layout/Resolver/TargetType/Product.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function getConstraints(): array
2929

3030
public function provideValue(Request $request): ?int
3131
{
32-
$product = $request->attributes->get('nglayouts_sylius_product');
32+
$product = $request->attributes->get('nglayouts_sylius_resource');
3333

3434
return $product instanceof ProductInterface ? $product->getId() : null;
3535
}

Diff for: lib/Layout/Resolver/TargetType/Taxon.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function getConstraints(): array
3232
*/
3333
public function provideValue(Request $request): ?array
3434
{
35-
$taxon = $request->attributes->get('nglayouts_sylius_taxon');
35+
$taxon = $request->attributes->get('nglayouts_sylius_resource');
3636
if (!$taxon instanceof TaxonInterface) {
3737
return null;
3838
}

Diff for: lib/Layout/Resolver/TargetType/TaxonProduct.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function getConstraints(): array
3535
*/
3636
public function provideValue(Request $request): ?array
3737
{
38-
$product = $request->attributes->get('nglayouts_sylius_product');
38+
$product = $request->attributes->get('nglayouts_sylius_resource');
3939
if (!$product instanceof ProductInterface) {
4040
return null;
4141
}

Diff for: tests/lib/Layout/Resolver/TargetType/ProductTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testValidationInvalid(): void
6868
public function testProvideValue(): void
6969
{
7070
$request = Request::create('/');
71-
$request->attributes->set('nglayouts_sylius_product', new ProductStub(42));
71+
$request->attributes->set('nglayouts_sylius_resource', new ProductStub(42));
7272

7373
self::assertSame(42, $this->targetType->provideValue($request));
7474
}

Diff for: tests/lib/Layout/Resolver/TargetType/TaxonProductTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function testProvideValue(): void
7878
}
7979

8080
$request = Request::create('/');
81-
$request->attributes->set('nglayouts_sylius_product', $product);
81+
$request->attributes->set('nglayouts_sylius_resource', $product);
8282

8383
self::assertSame([12, 13], $this->targetType->provideValue($request));
8484
}

Diff for: tests/lib/Layout/Resolver/TargetType/TaxonTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function testProvideValue(): void
7171
$taxon->setParent(new TaxonStub(24));
7272

7373
$request = Request::create('/');
74-
$request->attributes->set('nglayouts_sylius_taxon', $taxon);
74+
$request->attributes->set('nglayouts_sylius_resource', $taxon);
7575

7676
self::assertSame([42, 24], $this->targetType->provideValue($request));
7777
}

0 commit comments

Comments
 (0)