-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?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 AdvancedObjectSearchBundle\Factory\OpenSearch; | ||
|
||
use AdvancedObjectSearchBundle\Service; | ||
use AdvancedObjectSearchBundle\Tools\IndexConfigService; | ||
use OpenSearch\ClientBuilder; | ||
use Pimcore\Bundle\ElasticsearchClientBundle\SearchClient\ElasticsearchClientInterface; | ||
use Pimcore\Bundle\OpenSearchClientBundle\SearchClient\OpenSearchClientInterface; | ||
use Pimcore\SearchClient\SearchClientInterface; | ||
use Pimcore\Security\User\TokenStorageUserResolver; | ||
use Pimcore\Translation\Translator; | ||
use Psr\Container\ContainerInterface; | ||
use Psr\Log\LoggerInterface; | ||
use RuntimeException; | ||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||
|
||
/** | ||
* @internal | ||
* @deprecated will be removed in version 7.0 | ||
*/ | ||
final readonly class LegacyServiceFactory | ||
Check failure on line 36 in src/Factory/OpenSearch/LegacyServiceFactory.php GitHub Actions / Static Analysis with PHPStan (8.1, highest, false)
|
||
{ | ||
public function __construct( | ||
private LoggerInterface $logger, | ||
private TokenStorageUserResolver $userResolver, | ||
private EventDispatcherInterface $eventDispatcher, | ||
private Translator $translator, | ||
private IndexConfigService $indexConfigService, | ||
private SearchClientInterface $client | ||
) | ||
{ | ||
|
||
} | ||
|
||
public function create( | ||
ContainerInterface $filterLocator | ||
): Service | ||
{ | ||
$openSearchClient = match (true) { | ||
$this->client instanceof OpenSearchClientInterface => $this->client->getOriginalClient(), | ||
$this->client instanceof ElasticsearchClientInterface => ClientBuilder::create()->build(), | ||
default => null, | ||
}; | ||
|
||
if ($openSearchClient === null) { | ||
throw new RuntimeException('No client found for OpenSearch'); | ||
} | ||
|
||
$service = new Service( | ||
$this->logger, | ||
$this->userResolver, | ||
$filterLocator, | ||
$this->eventDispatcher, | ||
$this->translator, | ||
$this->indexConfigService, | ||
$openSearchClient | ||
); | ||
|
||
$service->setSearchClientInterface($this->client); | ||
|
||
return $service; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters