diff --git a/src/Api/FilterPublishedCommentQueryExtension.php b/src/Api/FilterPublishedCommentQueryExtension.php new file mode 100644 index 0000000..ff34d74 --- /dev/null +++ b/src/Api/FilterPublishedCommentQueryExtension.php @@ -0,0 +1,26 @@ +andWhere(sprintf("%s.state = 'published'", $qb->getRootAliases()[0])); + } + } + + public function applyToItem(QueryBuilder $qb, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, array $identifiers, string $operationName = null, array $context = []) + { + if (Comment::class === $resourceClass) { + $qb->andWhere(sprintf("%s.state = 'published'", $qb->getRootAliases()[0])); + } + } +}