Skip to content

Commit 5185f74

Browse files
committed
Added support for aggregations
1 parent 2cb46e2 commit 5185f74

File tree

6 files changed

+86
-1
lines changed

6 files changed

+86
-1
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"require-dev": {
2323
"phpunit/phpunit": "^9.0",
2424
"ezsystems/ezplatform-code-style": "^0.3",
25+
"ezsystems/ezplatform-solr-search-engine": "^3.3",
2526
"friendsofphp/php-cs-fixer": "^2.16",
2627
"phpstan/phpstan-phpunit": "^0.12.17",
2728
"symfony/maker-bundle": "^1.31"

src/DependencyInjection/IbexaFormattedTextLineExtension.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,20 @@ public function prepend(ContainerBuilder $container): void
3333

3434
$container->addResource(new FileResource($configFile));
3535
foreach (Yaml::parseFile($configFile) as $name => $config) {
36-
$container->prependExtensionConfig($name, $config);
36+
if ($container->hasExtension($name)) {
37+
$container->prependExtensionConfig($name, $config);
38+
}
3739
}
3840

3941
$this->prependJMSTranslation($container);
4042
}
4143

4244
private function prependJMSTranslation(ContainerBuilder $container): void
4345
{
46+
if (!$container->hasExtension('jms_translation')) {
47+
return ;
48+
}
49+
4450
$container->prependExtensionConfig('jms_translation', [
4551
'configs' => [
4652
'ibexa-formatted-textline' => [

src/IbexaFormattedTextLineBundle.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,28 @@
44

55
namespace AdamWojs\IbexaFormattedTextLineBundle;
66

7+
use Symfony\Component\Config\FileLocator;
8+
use Symfony\Component\DependencyInjection\ContainerBuilder;
9+
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
710
use Symfony\Component\HttpKernel\Bundle\Bundle;
811

912
final class IbexaFormattedTextLineBundle extends Bundle
1013
{
14+
public function build(ContainerBuilder $container)
15+
{
16+
parent::build($container);
17+
18+
$loader = new YamlFileLoader(
19+
$container,
20+
new FileLocator(__DIR__ . '/Resources/config')
21+
);
22+
23+
if ($container->hasExtension('ez_search_engine_solr')) {
24+
$loader->load('services_solr.yaml');
25+
}
26+
27+
if ($container->hasExtension('ezplatform_elastic_search_engine')) {
28+
$loader->load('services_es.yaml');
29+
}
30+
}
1131
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
public: false
6+
7+
ezplatform.search.elasticsearch.query.common.aggregation_visitor.field.formatted_textline_term:
8+
class: Ibexa\Platform\ElasticSearchEngine\Query\AggregationVisitor\TermAggregationVisitor
9+
factory: ['@Ibexa\Platform\ElasticSearchEngine\Query\AggregationVisitor\Factory\ContentFieldAggregationVisitorFactory', 'createTermAggregationVisitor']
10+
arguments:
11+
$aggregationClass: 'AdamWojs\IbexaFormattedTextLineBundle\Search\Query\Aggregation\FormattedTextLineTermAggregation'
12+
$searchIndexFieldName: 'value'
13+
tags:
14+
- { name: ezplatform.search.elasticsearch.query.content.aggregation_visitor }
15+
- { name: ezplatform.search.elasticsearch.query.location.aggregation_visitor }
16+
17+
ezplatform.search.elasticsearch.query.common.aggregation_result_extractor.field.formatted_textline_term:
18+
class: Ibexa\Platform\ElasticSearchEngine\Query\ResultExtractor\AggregationResultExtractor\TermAggregationResultExtractor
19+
arguments:
20+
$aggregationClass: 'AdamWojs\IbexaFormattedTextLineBundle\Search\Query\Aggregation\FormattedTextLineTermAggregation'
21+
tags:
22+
- { name: ezplatform.search.elasticsearch.query.content.aggregation_result_extractor }
23+
- { name: ezplatform.search.elasticsearch.query.location.aggregation_result_extractor }
24+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
services:
2+
_defaults:
3+
autowire: true
4+
autoconfigure: true
5+
public: false
6+
7+
ezplatform.search.solr.query.common.aggregation_visitor.field.formatted_textline_term:
8+
class: EzSystems\EzPlatformSolrSearchEngine\Query\Common\AggregationVisitor\TermAggregationVisitor
9+
factory: ['@EzSystems\EzPlatformSolrSearchEngine\Query\Common\AggregationVisitor\Factory\ContentFieldAggregationVisitorFactory', 'createTermAggregationVisitor']
10+
arguments:
11+
$aggregationClass: 'AdamWojs\IbexaFormattedTextLineBundle\Search\Query\Aggregation\FormattedTextLineTermAggregation'
12+
$searchIndexFieldName: 'value'
13+
tags:
14+
- { name: ezplatform.search.solr.query.content.aggregation_visitor }
15+
- { name: ezplatform.search.solr.query.location.aggregation_visitor }
16+
17+
ezplatform.search.solr.query.common.aggregation_result_extractor.field.formatted_textline_term:
18+
class: EzSystems\EzPlatformSolrSearchEngine\ResultExtractor\AggregationResultExtractor\TermAggregationResultExtractor
19+
arguments:
20+
$aggregationClass: 'AdamWojs\IbexaFormattedTextLineBundle\Search\Query\Aggregation\FormattedTextLineTermAggregation'
21+
tags:
22+
- { name: ezplatform.search.solr.query.content.aggregation_result_extractor }
23+
- { name: ezplatform.search.solr.query.location.aggregation_result_extractor }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace AdamWojs\IbexaFormattedTextLineBundle\Search\Query\Aggregation;
6+
7+
use eZ\Publish\API\Repository\Values\Content\Query\Aggregation\Field\AbstractFieldTermAggregation;
8+
9+
final class FormattedTextLineTermAggregation extends AbstractFieldTermAggregation
10+
{
11+
}

0 commit comments

Comments
 (0)