vendor/bitbag/elasticsearch-plugin/src/Finder/ProductAttributesFinder.php line 37

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file has been created by developers from BitBag.
  4.  * Feel free to contact us once you face any issues or want to start
  5.  * another great project.
  6.  * You can find more information about us on https://bitbag.io and write us
  7.  * an email on hello@bitbag.io.
  8.  */
  9. declare(strict_types=1);
  10. namespace BitBag\SyliusElasticsearchPlugin\Finder;
  11. use BitBag\SyliusElasticsearchPlugin\QueryBuilder\QueryBuilderInterface;
  12. use FOS\ElasticaBundle\Finder\FinderInterface;
  13. use Sylius\Component\Core\Model\TaxonInterface;
  14. final class ProductAttributesFinder implements ProductAttributesFinderInterface
  15. {
  16.     private FinderInterface $attributesFinder;
  17.     private QueryBuilderInterface $attributesByTaxonQueryBuilder;
  18.     private string $taxonsProperty;
  19.     public function __construct(
  20.         FinderInterface $attributesFinder,
  21.         QueryBuilderInterface $attributesByTaxonQueryBuilder,
  22.         string $taxonsProperty
  23.     ) {
  24.         $this->attributesFinder $attributesFinder;
  25.         $this->attributesByTaxonQueryBuilder $attributesByTaxonQueryBuilder;
  26.         $this->taxonsProperty $taxonsProperty;
  27.     }
  28.     public function findByTaxon(TaxonInterface $taxon): ?array
  29.     {
  30.         $data = [];
  31.         $data[$this->taxonsProperty] = strtolower($taxon->getCode());
  32.         $query $this->attributesByTaxonQueryBuilder->buildQuery($data);
  33.         return $this->attributesFinder->find($query20);
  34.     }
  35. }