vendor/store.shopware.com/swagenterprisesearchplatform/src/Boosting/BoostingProvider.php line 29

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Swag\EnterpriseSearch\Boosting;
  3. use Shopware\Core\Framework\Api\Context\SalesChannelApiSource;
  4. use Shopware\Core\Framework\Context;
  5. use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
  6. class BoostingProvider
  7. {
  8.     /**
  9.      * @var BoostingRepository
  10.      */
  11.     private $boostingRepository;
  12.     /**
  13.      * @var ResolverRegistry
  14.      */
  15.     private $resolverRegistry;
  16.     public function __construct(
  17.         BoostingRepository $boostingRepository,
  18.         ResolverRegistry $resolverRegistry
  19.     ) {
  20.         $this->boostingRepository $boostingRepository;
  21.         $this->resolverRegistry $resolverRegistry;
  22.     }
  23.     public function getActiveBoostings(EntityDefinition $definitionContext $context): array
  24.     {
  25.         $contextSource $context->getSource();
  26.         if (!$contextSource instanceof SalesChannelApiSource) {
  27.             return [];
  28.         }
  29.         $streamResolver $this->resolverRegistry->getResolver($definition);
  30.         $boostingCollection $this->boostingRepository->getBoostings(
  31.             $definition,
  32.             $context,
  33.             $contextSource,
  34.             $streamResolver->getType()
  35.         );
  36.         return $streamResolver->createBoostingCombination($boostingCollection$context);
  37.     }
  38.     public function getActiveBoostingsBySalesChannelIds(EntityDefinition $definitionContext $context, array $salesChannelIds): array
  39.     {
  40.         $contextSource $context->getSource();
  41.         if (!$contextSource instanceof SalesChannelApiSource) {
  42.             return [];
  43.         }
  44.         $streamResolver $this->resolverRegistry->getResolver($definition);
  45.         $boostingCollection $this->boostingRepository->getBoostingsBySalesChannelids(
  46.             $definition,
  47.             $context,
  48.             $salesChannelIds,
  49.             $streamResolver->getType()
  50.         );
  51.         return $streamResolver->createBoostingCombination($boostingCollection$context);
  52.     }
  53. }