for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sylius\ShopApiPlugin\Validator;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
final class ChannelWithGivenCodeDoesNotExistsValidator extends ConstraintValidator
{
/**
* @var ChannelRepositoryInterface
*/
private $channelRepository;
* @param ChannelRepositoryInterface $channelRepository
public function __construct(ChannelRepositoryInterface $channelRepository)
$this->channelRepository = $channelRepository;
}
* {@inheritdoc}
public function validate($token, Constraint $constraint)
if (null === $this->channelRepository->findOneByCode($token)) {
$this->context->addViolation($constraint->message);