Skip to content

Commit

Permalink
Merge pull request #12 from dachcom-digital/coding-standard/refactor-…
Browse files Browse the repository at this point in the history
…main

[CS] Refactor
  • Loading branch information
solverat authored Jan 6, 2025
2 parents 663909b + 3c07360 commit 01c452f
Show file tree
Hide file tree
Showing 25 changed files with 302 additions and 35 deletions.
14 changes: 13 additions & 1 deletion src/Builder/ClientBuilder.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Builder;

use DynamicSearchBundle\Logger\LoggerInterface;
Expand All @@ -9,7 +20,8 @@ class ClientBuilder implements ClientBuilderInterface
{
public function __construct(
protected LoggerInterface $logger
) {}
) {
}

public function build(array $indexOptions): Client
{
Expand Down
11 changes: 11 additions & 0 deletions src/Builder/ClientBuilderInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Builder;

use OpenSearch\Client;
Expand Down
13 changes: 13 additions & 0 deletions src/Command/RebuildIndexCommand.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Command;

use DsOpenSearchBundle\Manager\IndexManager;
Expand Down Expand Up @@ -34,6 +45,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

if (empty($contextName)) {
$output->writeln('<error>no context definition name given</error>');

return Command::FAILURE;
}

Expand All @@ -52,6 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->indexManager->rebuildIndex($contextName);
} catch (\Throwable $e) {
$output->writeln(sprintf('<error>Error rebuilding index mapping: %s</error>', $e->getMessage()));

return Command::FAILURE;
}

Expand Down
15 changes: 12 additions & 3 deletions src/Controller/Admin/IndexController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Controller\Admin;

use DsOpenSearchBundle\Manager\IndexManager;
Expand All @@ -11,8 +22,7 @@ class IndexController extends AdminAbstractController
{
public function __construct(
protected IndexManager $indexManager
)
{
) {
}

public function rebuildMappingAction(Request $request): Response
Expand All @@ -31,5 +41,4 @@ public function rebuildMappingAction(Request $request): Response

return new Response();
}

}
11 changes: 11 additions & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
Expand Down
15 changes: 13 additions & 2 deletions src/DependencyInjection/DsOpenSearchExtension.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\DependencyInjection;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;

class DsOpenSearchExtension extends Extension
{
Expand Down
12 changes: 11 additions & 1 deletion src/DsOpenSearchBundle.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle;

use DynamicSearchBundle\Provider\Extension\ProviderBundleInterface;
use Pimcore\Extension\Bundle\AbstractPimcoreBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;

final class DsOpenSearchBundle extends AbstractPimcoreBundle implements ProviderBundleInterface
{
Expand Down
17 changes: 14 additions & 3 deletions src/DsOpenSearchEvents.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle;

final class DsOpenSearchEvents
{
/**
* The BULK event occurs before during the processing of bulk method
* The BULK event occurs before during the processing of bulk method.
*/
public const BULK = 'ds_opensearch.bulk';

/**
* The PRE_COMMIT event occurs before committing queries to ES
* The PRE_COMMIT event occurs before committing queries to ES.
*/
public const PRE_COMMIT = 'ds_opensearch.pre_commit';

/**
* The POST_COMMIT event occurs after committing queries to ES
* The POST_COMMIT event occurs after committing queries to ES.
*/
public const POST_COMMIT = 'ds_opensearch.post_commit';

Expand Down
12 changes: 11 additions & 1 deletion src/EventListener/Admin/AssetListener.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\EventListener\Admin;

use Pimcore\Event\BundleManager\PathsEvent;
Expand All @@ -21,5 +32,4 @@ public function addJsFiles(PathsEvent $event): void
'/bundles/dsopensearch/js/backend/settings.js',
]);
}

}
11 changes: 11 additions & 0 deletions src/Exception/ClientException.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Exception;

final class ClientException extends \Exception
Expand Down
11 changes: 11 additions & 0 deletions src/Index/Field/AbstractType.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Index\Field;

use DynamicSearchBundle\Index\IndexFieldInterface;
Expand Down
11 changes: 11 additions & 0 deletions src/Index/Field/DynamicField.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Index\Field;

final class DynamicField extends AbstractType
Expand Down
11 changes: 11 additions & 0 deletions src/Index/Field/ExplicitField.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Index\Field;

final class ExplicitField extends AbstractType
Expand Down
20 changes: 14 additions & 6 deletions src/Manager/IndexManager.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Manager;

use DsOpenSearchBundle\Builder\ClientBuilderInterface;
Expand All @@ -11,13 +22,11 @@

class IndexManager
{

public function __construct(
protected ContextDefinitionBuilderInterface $contextDefinitionBuilder,
protected IndexDocumentGeneratorInterface $indexDocumentGenerator,
protected ClientBuilderInterface $clientBuilder,
)
{
) {
}

public function rebuildIndex(string $contextName): void
Expand All @@ -34,7 +43,8 @@ public function rebuildIndex(string $contextName): void
throw new \Exception(
sprintf(
'%s. (The current context index provider also requires pre-configured indices. Please make sure your document definition implements the "%s" interface)',
$e->getMessage(), PreConfiguredIndexProviderInterface::class
$e->getMessage(),
PreConfiguredIndexProviderInterface::class
)
);
}
Expand All @@ -59,6 +69,4 @@ public function rebuildIndex(string $contextName): void

$indexService->createIndex($indexDocument);
}


}
12 changes: 12 additions & 0 deletions src/Normalizer/DocumentRawNormalizer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Normalizer;

use DynamicSearchBundle\Context\ContextDefinitionInterface;
Expand All @@ -25,6 +36,7 @@ public function normalize(RawResultInterface $rawResult, ContextDefinitionInterf
{
if ($rawResult->hasParameter('fullDatabaseResponse') === false) {
$message = sprintf('Parameter "fullDatabaseResponse" is required to normalize raw result but is missing');

throw new NormalizerException($message, __CLASS__);
}

Expand Down
12 changes: 12 additions & 0 deletions src/Normalizer/DocumentSourceNormalizer.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?php

/*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - DACHCOM Commercial License (DCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) DACHCOM.DIGITAL AG (https://www.dachcom-digital.com)
* @license GPLv3 and DCL
*/

namespace DsOpenSearchBundle\Normalizer;

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

if (!is_array($data)) {
$message = sprintf('Data needs to be type of "array", "%s" given', is_object($data) ? get_class($data) : gettype($data));

throw new NormalizerException($message, __CLASS__);
}

Expand Down
Loading

0 comments on commit 01c452f

Please sign in to comment.