Skip to content

Commit 1b9fa42

Browse files
committed
Tag HTTP cache when visiting content and location
1 parent bffaeed commit 1b9fa42

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

bundle/DependencyInjection/CompilerPass/ContentTypePartProviderPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public function process(ContainerBuilder $container): void
4141

4242
$container
4343
->findDefinition(self::SERVICE_NAME)
44-
->setArgument(0, $services);
44+
->setArgument(1, $services);
4545
}
4646
}

bundle/Resources/config/services/page/visitors.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ services:
6161
netgen.openapi_ibexa.page.output.visitor.site_api.content:
6262
class: Netgen\OpenApiIbexa\Page\Output\Visitor\SiteApi\ContentVisitor
6363
arguments:
64+
- '@Ibexa\HttpCache\Handler\TagHandler'
6465
- []
6566
tags:
6667
- { name: netgen.openapi_ibexa.page.output.visitor }
6768

6869
netgen.openapi_ibexa.page.output.visitor.site_api.location:
6970
class: Netgen\OpenApiIbexa\Page\Output\Visitor\SiteApi\LocationVisitor
71+
arguments:
72+
- '@Ibexa\HttpCache\Handler\TagHandler'
7073
tags:
7174
- { name: netgen.openapi_ibexa.page.output.visitor }
7275

lib/Page/Output/Visitor/SiteApi/ContentVisitor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Netgen\OpenApiIbexa\Page\Output\Visitor\SiteApi;
66

7+
use Ibexa\HttpCache\Handler\TagHandler;
78
use Netgen\IbexaSiteApi\API\Values\Content;
89
use Netgen\OpenApiIbexa\Page\Output\OutputVisitor;
910
use Netgen\OpenApiIbexa\Page\Output\VisitorInterface;
@@ -19,6 +20,7 @@ final class ContentVisitor implements VisitorInterface
1920
* @param array<string, \Netgen\OpenApiIbexa\Page\Output\Visitor\SiteApi\ContentTypePartProviderInterface[]> $contentTypePartProviders
2021
*/
2122
public function __construct(
23+
private TagHandler $tagHandler,
2224
private array $contentTypePartProviders,
2325
) {}
2426

@@ -38,6 +40,8 @@ public function visit(object $value, OutputVisitor $outputVisitor, array $parame
3840
$contentTypeParts = [...$contentTypeParts, ...$contentTypePartProvider->provideContentTypeParts($value)];
3941
}
4042

43+
$this->tagHandler->addContentTags([$value->contentInfo->id]);
44+
4145
return [
4246
'id' => $value->contentInfo->id,
4347
'type' => 'content',

lib/Page/Output/Visitor/SiteApi/LocationVisitor.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Netgen\OpenApiIbexa\Page\Output\Visitor\SiteApi;
66

7+
use Ibexa\HttpCache\Handler\TagHandler;
78
use Netgen\IbexaSiteApi\API\Values\Location;
89
use Netgen\OpenApiIbexa\Page\Output\OutputVisitor;
910
use Netgen\OpenApiIbexa\Page\Output\VisitorInterface;
@@ -15,6 +16,10 @@
1516
*/
1617
final class LocationVisitor implements VisitorInterface
1718
{
19+
public function __construct(
20+
private TagHandler $tagHandler,
21+
) {}
22+
1823
public function accept(object $value): bool
1924
{
2025
return $value instanceof Location;
@@ -25,6 +30,8 @@ public function accept(object $value): bool
2530
*/
2631
public function visit(object $value, OutputVisitor $outputVisitor, array $parameters = []): iterable
2732
{
33+
$this->tagHandler->addLocationTags([$value->id]);
34+
2835
return [
2936
'id' => $value->id,
3037
'type' => 'location',

0 commit comments

Comments
 (0)