Skip to content

Commit ce3d222

Browse files
authored
Merge pull request #30 from dachcom-digital/coding-standard/refactor-master
[CS] Refactor
2 parents 0c8c87a + dbf5e7e commit ce3d222

22 files changed

+324
-97
lines changed

src/Builder/ClientBuilder.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\Builder;
415

516
use DynamicSearchBundle\Logger\LoggerInterface;
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\Builder;
415

516
use Elasticsearch\Client;
617

718
interface ClientBuilderInterface
819
{
920
public function build(array $indexOptions): Client;
10-
}
21+
}

src/Command/RebuildIndexCommand.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\Command;
415

516
use DsElasticSearchBundle\Builder\ClientBuilderInterface;
@@ -40,13 +51,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
4051

4152
if (empty($contextName)) {
4253
$output->writeln('<error>no context definition name given</error>');
54+
4355
return 0;
4456
}
4557

4658
$contextDefinition = $this->contextDefinitionBuilder->buildContextDefinition($contextName, ContextDefinitionInterface::CONTEXT_DISPATCH_TYPE_INDEX);
4759

4860
if (!$contextDefinition instanceof ContextDefinitionInterface) {
4961
$output->writeln(sprintf('<error>no context definition with name "%s" found</error>', $contextName));
62+
5063
return 0;
5164
}
5265

@@ -56,7 +69,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5669
$output->writeln(
5770
sprintf(
5871
'%s. (The current context index provider also requires pre-configured indices. Please make sure your document definition implements the "%s" interface)',
59-
$e->getMessage(), PreConfiguredIndexProviderInterface::class
72+
$e->getMessage(),
73+
PreConfiguredIndexProviderInterface::class
6074
)
6175
);
6276

@@ -80,7 +94,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8094
$indexService = new IndexPersistenceService($client, $options);
8195

8296
if ($indexService->indexExists()) {
83-
8497
/** @var QuestionHelper $helper */
8598
$helper = $this->getHelper('question');
8699

@@ -96,6 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
96109
$indexService->dropIndex();
97110
} catch (\Throwable $e) {
98111
$output->writeln(sprintf('Error while dropping index: %s', $e->getMessage()));
112+
99113
return 0;
100114
}
101115
}
@@ -104,6 +118,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
104118
$indexService->createIndex($indexDocument);
105119
} catch (\Throwable $e) {
106120
$output->writeln(sprintf('Error while creating index: %s', $e->getMessage()));
121+
107122
return 0;
108123
}
109124

src/DependencyInjection/Configuration.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\DependencyInjection;
415

516
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
@@ -11,4 +22,4 @@ public function getConfigTreeBuilder(): TreeBuilder
1122
{
1223
return new TreeBuilder('ds_elasticsearch');
1324
}
14-
}
25+
}

src/DependencyInjection/DsElasticSearchExtension.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\DependencyInjection;
415

16+
use Symfony\Component\Config\FileLocator;
17+
use Symfony\Component\DependencyInjection\ContainerBuilder;
518
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
619
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
7-
use Symfony\Component\DependencyInjection\ContainerBuilder;
8-
use Symfony\Component\Config\FileLocator;
920

1021
class DsElasticSearchExtension extends Extension
1122
{
@@ -17,4 +28,4 @@ public function load(array $configs, ContainerBuilder $container): void
1728
$loader = new YamlFileLoader($container, new FileLocator([__DIR__ . '/../../config']));
1829
$loader->load('services.yaml');
1930
}
20-
}
31+
}

src/DsElasticSearchBundle.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle;
415

516
use DynamicSearchBundle\Provider\Extension\ProviderBundleInterface;

src/DsElasticSearchEvents.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle;
415

516
final class DsElasticSearchEvents
617
{
718
/**
8-
* The BULK event occurs before during the processing of bulk method
19+
* The BULK event occurs before during the processing of bulk method.
920
*/
1021
public const BULK = 'ds_elasticsearch.bulk';
1122

1223
/**
13-
* The PRE_COMMIT event occurs before committing queries to ES
24+
* The PRE_COMMIT event occurs before committing queries to ES.
1425
*/
1526
public const PRE_COMMIT = 'ds_elasticsearch.pre_commit';
1627

1728
/**
18-
* The POST_COMMIT event occurs after committing queries to ES
29+
* The POST_COMMIT event occurs after committing queries to ES.
1930
*/
2031
public const POST_COMMIT = 'ds_elasticsearch.post_commit';
2132

src/Exception/ClientException.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\Exception;
415

516
final class ClientException extends \Exception

src/Index/Field/AbstractType.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\Index\Field;
415

516
use DynamicSearchBundle\Index\IndexFieldInterface;

src/Index/Field/DynamicField.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\Index\Field;
415

516
final class DynamicField extends AbstractType

src/Index/Field/ExplicitField.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\Index\Field;
415

516
final class ExplicitField extends AbstractType

src/Normalizer/DocumentRawNormalizer.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\Normalizer;
415

516
use DynamicSearchBundle\Context\ContextDefinitionInterface;
@@ -25,6 +36,7 @@ public function normalize(RawResultInterface $rawResult, ContextDefinitionInterf
2536
{
2637
if ($rawResult->hasParameter('fullDatabaseResponse') === false) {
2738
$message = sprintf('Parameter "fullDatabaseResponse" is required to normalize raw result but is missing');
39+
2840
throw new NormalizerException($message, __CLASS__);
2941
}
3042

src/Normalizer/DocumentSourceNormalizer.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\Normalizer;
415

516
use DynamicSearchBundle\Context\ContextDefinitionInterface;
@@ -27,6 +38,7 @@ public function normalize(RawResultInterface $rawResult, ContextDefinitionInterf
2738

2839
if (!is_array($data)) {
2940
$message = sprintf('Data needs to be type of "array", "%s" given', is_object($data) ? get_class($data) : gettype($data));
41+
3042
throw new NormalizerException($message, __CLASS__);
3143
}
3244

src/OutputChannel/Filter/AggregationFilter.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
<?php
22

3+
/*
4+
* This source file is available under two different licenses:
5+
* - GNU General Public License version 3 (GPLv3)
6+
* - DACHCOM Commercial License (DCL)
7+
* Full copyright and license information is available in
8+
* LICENSE.md which is distributed with this source code.
9+
*
10+
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
11+
* @license GPLv3 and DCL
12+
*/
13+
314
namespace DsElasticSearchBundle\OutputChannel\Filter;
415

516
use DynamicSearchBundle\EventDispatcher\OutputChannelModifierEventDispatcher;
@@ -31,7 +42,7 @@ public function configureOptions(OptionsResolver $resolver): void
3142
$resolver->setAllowedTypes('relation_label', ['closure', 'null']);
3243
$resolver->setAllowedTypes('field', ['string']);
3344
$resolver->setAllowedTypes('query_type', ['string']);
34-
45+
3546
$resolver->setDefaults([
3647
'query_type' => BoolQuery::MUST,
3748
'show_in_frontend' => true,
@@ -96,7 +107,7 @@ public function buildViewVars(RawResultInterface $rawResult, $filterValues, $que
96107
$response = $rawResult->getParameter('fullDatabaseResponse');
97108

98109
$viewVars = [
99-
'name' => $this->name,
110+
'name' => $this->name,
100111
'template' => [sprintf('%s/%s.html.twig', self::VIEW_TEMPLATE_PATH, $this->name), sprintf('%s/aggregation.html.twig', self::VIEW_TEMPLATE_PATH)],
101112
'label' => $this->options['label'],
102113
'multiple' => $this->options['multiple'],
@@ -119,7 +130,6 @@ protected function addQueryFilter(Search $query, array $queryFields): void
119130
}
120131

121132
foreach ($queryFields as $key => $value) {
122-
123133
if ($key !== $this->name) {
124134
continue;
125135
}
@@ -159,7 +169,6 @@ protected function buildResultArray(array $buckets): array
159169

160170
$values = [];
161171
foreach ($buckets as $bucket) {
162-
163172
$relationLabel = null;
164173
if ($this->options['relation_label'] !== null) {
165174
$relationLabel = call_user_func($this->options['relation_label'], $bucket['key'], $queryFields['locale'] ?? null);

0 commit comments

Comments
 (0)