custom/plugins/SwagEnterpriseSearchPlatform/src/Relevance/Bridge/ElasticsearchHelperDecorator.php line 94

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Swag\EnterpriseSearch\Relevance\Bridge;
  3. use ONGR\ElasticsearchDSL\Search;
  4. use Shopware\Core\Framework\Context;
  5. use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  7. use Shopware\Elasticsearch\Framework\ElasticsearchHelper;
  8. use Swag\EnterpriseSearch\Relevance\InvalidContextSourceException;
  9. use Swag\EnterpriseSearch\Relevance\TermQueryBuilder;
  10. /**
  11.  * @deprecated: Will be removed with the drop of shopware 6.2 support - Use {@see \Swag\EnterpriseSearch\Relevance\ElasticsearchHelperDecorator} instead
  12.  */
  13. class ElasticsearchHelperDecorator extends ElasticsearchHelper
  14. {
  15.     /**
  16.      * @var ElasticsearchHelper
  17.      */
  18.     private $decorated;
  19.     /**
  20.      * @var TermQueryBuilder
  21.      */
  22.     private $termQueryBuilder;
  23.     public function __construct(
  24.         ElasticsearchHelper $decorated,
  25.         TermQueryBuilder $termQueryBuilder
  26.     ) {
  27.         $this->decorated $decorated;
  28.         $this->termQueryBuilder $termQueryBuilder;
  29.     }
  30.     public function addTerm(Criteria $criteriaSearch $searchContext $context, ?EntityDefinition $definition null): void
  31.     {
  32.         if ($definition) {
  33.             try {
  34.                 $this->termQueryBuilder->addTermQuery($definition$criteria$search$context);
  35.             } catch (InvalidContextSourceException $e) {
  36.                 $this->decorated->addTerm($criteria$search$context$definition);
  37.             }
  38.             return;
  39.         }
  40.         $this->decorated->addTerm($criteria$search$context$definition);
  41.     }
  42.     public function logOrThrowException(\Throwable $exception): bool
  43.     {
  44.         return $this->decorated->logOrThrowException($exception);
  45.     }
  46.     public function logAndThrowException(\Throwable $exception): bool
  47.     {
  48.         if (method_exists($this->decorated'logAndThrowException')) {
  49.             return $this->decorated->logAndThrowException($exception);
  50.         }
  51.         return false;
  52.     }
  53.     public function getIndexName(EntityDefinition $definitionstring $languageId): string
  54.     {
  55.         return $this->decorated->getIndexName($definition$languageId);
  56.     }
  57.     public function allowIndexing(): bool
  58.     {
  59.         return $this->decorated->allowIndexing();
  60.     }
  61.     /**
  62.      * @deprecated tag:v6.5.0 - Parameter $criteria will be required
  63.      */
  64.     public function allowSearch(EntityDefinition $definitionContext $context, ?Criteria $criteria null): bool
  65.     {
  66.         try {
  67.             return $this->decorated->allowSearch($definition$context$criteria);
  68.         } catch (\RuntimeException $e) {
  69.             return false;
  70.         }
  71.     }
  72.     public function handleIds(EntityDefinition $definitionCriteria $criteriaSearch $searchContext $context): void
  73.     {
  74.         $this->decorated->handleIds($definition$criteria$search$context);
  75.     }
  76.     public function addFilters(EntityDefinition $definitionCriteria $criteriaSearch $searchContext $context): void
  77.     {
  78.         $this->decorated->addFilters($definition$criteria$search$context);
  79.     }
  80.     public function addPostFilters(EntityDefinition $definitionCriteria $criteriaSearch $searchContext $context): void
  81.     {
  82.         $this->decorated->addPostFilters($definition$criteria$search$context);
  83.     }
  84.     public function addQueries(EntityDefinition $definitionCriteria $criteriaSearch $searchContext $context): void
  85.     {
  86.         $this->decorated->addQueries($definition$criteria$search$context);
  87.     }
  88.     public function addSortings(EntityDefinition $definitionCriteria $criteriaSearch $searchContext $context): void
  89.     {
  90.         $this->decorated->addSortings($definition$criteria$search$context);
  91.     }
  92.     public function addAggregations(EntityDefinition $definitionCriteria $criteriaSearch $searchContext $context): void
  93.     {
  94.         $this->decorated->addAggregations($definition$criteria$search$context);
  95.     }
  96.     public function setEnabled(bool $enabled): ElasticsearchHelper
  97.     {
  98.         return $this->decorated->setEnabled($enabled);
  99.     }
  100.     public function isSupported(EntityDefinition $definition): bool
  101.     {
  102.         return $this->decorated->isSupported($definition);
  103.     }
  104. }