Skip to content

Commit

Permalink
feat: add search client adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
lukmzig committed Oct 31, 2024
1 parent a752cf4 commit 7205e64
Show file tree
Hide file tree
Showing 4 changed files with 388 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"sort-packages": true
},
"require": {
"pimcore/pimcore": "^11.x-dev",
"elasticsearch/elasticsearch": "^8.0",
"symfony/config": "^5.2.0 || ^6.0",
"symfony/dependency-injection": "^5.2.0 || ^6.0",
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 7205e64

Please sign in to comment.