-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathNestedFieldQueryBuilder.php
More file actions
44 lines (37 loc) · 1.04 KB
/
NestedFieldQueryBuilder.php
File metadata and controls
44 lines (37 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php declare(strict_types=1);
namespace Shopware\Elasticsearch;
use OpenSearchDSL\BuilderInterface;
use OpenSearchDSL\Query\Joining\NestedQuery;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\Log\Package;
use Shopware\Elasticsearch\Product\SearchFieldConfig;
/**
* @internal
*/
#[Package('inventory')]
class NestedFieldQueryBuilder extends AbstractFieldQueryBuilder
{
/**
* @internal
*/
public function __construct(
private readonly AbstractFieldQueryBuilder $fieldQueryBuilder,
) {
}
public function getDecorated(): AbstractFieldQueryBuilder
{
return $this->fieldQueryBuilder;
}
public function build(
ResolvedField $field,
string $token,
SearchFieldConfig $config,
Context $context,
): ?BuilderInterface {
$query = $this->getDecorated()->build($field, $token, $config, $context);
if (!$query || $field->getRoot() === null) {
return $query;
}
return new NestedQuery($field->getRoot(), $query);
}
}