for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* another great project.
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/
declare(strict_types=1);
namespace BitBag\SyliusVueStorefrontPlugin\Sylius\Validator\Cart;
use Sylius\Component\Core\Model\OrderInterface;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
final class CartExistsValidator extends ConstraintValidator
{
/** @var OrderRepositoryInterface */
private $orderRepository;
public function __construct(OrderRepositoryInterface $orderRepository)
$this->orderRepository = $orderRepository;
}
public function validate($cartId, Constraint $constraint): void
if (null === $this->orderRepository->findOneBy(['tokenValue' => $cartId, 'state' => OrderInterface::STATE_CART])) {
$this->context->addViolation($constraint->message);