From ec2f5c572b15ddb820016cceee8d295d70694456 Mon Sep 17 00:00:00 2001 From: valantic-cx-alps <110961873+valantic-cx-alps@users.noreply.github.com> Date: Fri, 6 Jun 2025 08:47:06 +0200 Subject: [PATCH] Added prebuild event for extending possibilities to hook into graphql queries --- src/Event/GraphQL/ListingEvents.php | 7 +++++++ src/GraphQL/Resolver/QueryType.php | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/Event/GraphQL/ListingEvents.php b/src/Event/GraphQL/ListingEvents.php index 89b718cb..699969e0 100644 --- a/src/Event/GraphQL/ListingEvents.php +++ b/src/Event/GraphQL/ListingEvents.php @@ -14,6 +14,13 @@ final class ListingEvents { + /** + * @Event("Symfony\Component\EventDispatcher\GenericEvent") + * + * @var string + */ + const PRE_BUILD = 'pimcore.datahub.graphql.listing.preBuild'; + /** * @Event("Pimcore\Bundle\DataHubBundle\Event\GraphQL\Model\ListingEvent") * diff --git a/src/GraphQL/Resolver/QueryType.php b/src/GraphQL/Resolver/QueryType.php index db03ae87..d45b8304 100644 --- a/src/GraphQL/Resolver/QueryType.php +++ b/src/GraphQL/Resolver/QueryType.php @@ -370,6 +370,12 @@ public function resolveListing($value = null, $args = [], $context = [], ?Resolv $this->getGraphQlService()->getLocaleService()->setLocale($args['defaultLanguage']); } + $event = new GenericEvent( + arguments: $args, + ); + + $this->eventDispatcher->dispatch($event, ListingEvents::PRE_BUILD); + $modelFactory = $this->getGraphQlService()->getModelFactory(); $listClass = 'Pimcore\\Model\\DataObject\\' . ucfirst($this->class->getName()) . '\\Listing'; /** @var Listing\Concrete $objectList */