<?php declare(strict_types=1);
namespace Swag\EnterpriseSearch\IndexingQuery;
use Shopware\Core\Framework\Api\Context\SalesChannelApiSource;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Swag\EnterpriseSearch\Boosting\BoostingCollection;
use Swag\EnterpriseSearch\Boosting\BoostingRepository;
class BoostingRepositoryDecorator extends BoostingRepository
{
/**
* @var BoostingRepository
*/
private $decorated;
/**
* @var IndexingQueryService
*/
private $indexingQueryService;
public function __construct(
BoostingRepository $decorated,
IndexingQueryService $indexingQueryService
) {
$this->decorated = $decorated;
$this->indexingQueryService = $indexingQueryService;
}
public function getBoostings(EntityDefinition $definition, Context $context, SalesChannelApiSource $apiSource, string $streamType): BoostingCollection
{
$indexQuery = $this->indexingQueryService->getQueries($definition, $context);
if ($indexQuery) {
return $indexQuery->boostingCollection;
}
return $this->decorated->getBoostings($definition, $context, $apiSource, $streamType);
}
}