Skip to content

Commit

Permalink
[Improvement]: Add search client adapter (#13)
Browse files Browse the repository at this point in the history
* feat: add search client adapter

* add missing search client adapter methods

* update static analysis

* update dependencies

* handle 404 exceptions
  • Loading branch information
lukmzig authored Nov 7, 2024
1 parent a752cf4 commit bb3bcf4
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ jobs:
strategy:
matrix:
include:
- { php-version: "7.4", dependencies: "lowest", pimcore_version: "", phpstan_args: "", experimental: false }
- { php-version: "8.0", dependencies: "highest", pimcore_version: "", phpstan_args: "", experimental: false }
- { php-version: "8.1", dependencies: "highest", pimcore_version: "", phpstan_args: "", experimental: false }
#- { php-version: "8.1", dependencies: "highest", pimcore_version: "11.x-dev", phpstan_args: "", experimental: true }
steps:
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
"sort-packages": true
},
"require": {
"php": "^8.1",
"pimcore/pimcore": "^11.x-dev",
"elasticsearch/elasticsearch": "^8.0",
"symfony/config": "^5.2.0 || ^6.0",
"symfony/dependency-injection": "^5.2.0 || ^6.0",
"symfony/http-kernel": "^5.2.0 || ^6.0",
"psr/log": "*"
},
"require-dev": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use Elastic\Elasticsearch\Client;
use Pimcore\Bundle\ElasticsearchClientBundle\EsClientFactory;
use Pimcore\Bundle\ElasticsearchClientBundle\SearchClient\SearchClient;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
Expand All @@ -28,6 +29,7 @@
class PimcoreElasticsearchClientExtension extends ConfigurableExtension implements PrependExtensionInterface
{
const CLIENT_SERVICE_PREFIX = 'pimcore.elasticsearch_client.';
const PIMCORE_CLIENT_PREFIX = 'pimcore.elasticsearch.custom_client.';

protected function loadInternal(array $mergedConfig, ContainerBuilder $container)
{
Expand All @@ -43,6 +45,10 @@ protected function loadInternal(array $mergedConfig, ContainerBuilder $container
$definition->setArgument('$configuration', $clientConfig);
$definition->addTag('monolog.logger', ['channel' => $clientConfig['logger_channel']]);
$definitions[self::CLIENT_SERVICE_PREFIX . $name] = $definition;

$customClientDefinition = new Definition(SearchClient::class);
$customClientDefinition->setArgument('$client', $definition);
$definitions[self::PIMCORE_CLIENT_PREFIX . $name] = $customClientDefinition;
}

$container->addDefinitions($definitions);
Expand Down
25 changes: 25 additions & 0 deletions src/SearchClient/ElasticsearchClientInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);

/**
* Pimcore
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - Pimcore Commercial License (PCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
* @license http://www.pimcore.org/license GPLv3 and PCL
*/

namespace Pimcore\Bundle\ElasticsearchClientBundle\SearchClient;

use Elastic\Elasticsearch\Client;
use Pimcore\SearchClient\SearchClientInterface;

interface ElasticsearchClientInterface extends SearchClientInterface
{
public function getOriginalClient(): Client;
}
Loading

0 comments on commit bb3bcf4

Please sign in to comment.