66
77use Generator ;
88use Ibexa \Contracts \Core \SiteAccess \ConfigResolverInterface ;
9+ use Ibexa \HttpCache \Handler \TagHandler ;
910use Netgen \IbexaSiteApi \API \Values \Content ;
1011use Netgen \IbexaSiteApi \API \Values \Location ;
1112use Netgen \Layouts \API \Values \Block \Block ;
1819use Netgen \OpenApiIbexa \Page \Output \VisitorInterface ;
1920use ReflectionClass ;
2021
22+ use function is_int ;
23+
2124/**
2225 * @implements \Netgen\OpenApiIbexa\Page\Output\VisitorInterface<\Netgen\Layouts\API\Values\Block\Block>
2326 */
2427final class BlockVisitor implements VisitorInterface
2528{
2629 public function __construct (
30+ private TagHandler $ tagHandler ,
2731 private PagerFactory $ pagerFactory ,
2832 private ConfigResolverInterface $ configResolver ,
2933 ) {}
@@ -48,11 +52,24 @@ public function visit(object $value, OutputVisitor $outputVisitor, array $parame
4852 ];
4953
5054 if ($ value ->hasCollection ('default ' )) {
55+ /** @var \Netgen\Layouts\API\Values\Collection\Collection $collection */
56+ $ collection = $ value ->getCollection ('default ' );
57+
5158 /** @var \Netgen\Layouts\Collection\Result\ResultSet $resultSet */
5259 $ resultSet = $ this ->pagerFactory
53- ->getPager ($ value -> getCollection ( ' default ' ) , 1 )
60+ ->getPager ($ collection , 1 )
5461 ->getCurrentPageResults ();
5562
63+ $ query = $ collection ->getQuery ();
64+
65+ $ parentLocation = $ query ?->hasParameter('parent_location_id ' ) === true
66+ ? $ query ->getParameter ('parent_location_id ' )->getValue ()
67+ : null ;
68+
69+ if (is_int ($ parentLocation )) {
70+ $ this ->tagHandler ->addLocationTags ([$ parentLocation ]);
71+ }
72+
5673 $ properties ['items ' ] = [...$ this ->visitItems ($ resultSet , $ outputVisitor )];
5774 }
5875
0 commit comments