for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Component\Core\Provider;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Repository\PromotionRepositoryInterface;
use Sylius\Component\Promotion\Model\PromotionSubjectInterface;
use Sylius\Component\Promotion\Provider\PreQualifiedPromotionsProviderInterface;
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
/**
* @author Mateusz Zalewski <[email protected]>
class ActivePromotionsByChannelProvider implements PreQualifiedPromotionsProviderInterface
{
* @var PromotionRepositoryInterface
private $promotionRepository;
* @param PromotionRepositoryInterface $promotionRepository
public function __construct(PromotionRepositoryInterface $promotionRepository)
$this->promotionRepository = $promotionRepository;
}
* {@inheritdoc}
public function getPromotions(PromotionSubjectInterface $subject)
if (!$subject instanceof OrderInterface) {
throw new UnexpectedTypeException($subject, OrderInterface::class);
$channel = $subject->getChannel();
$promotions = $this->promotionRepository->findActiveByChannel($channel);
return $promotions;