vendor/shopware/core/Checkout/Cart/Validator.php line 25

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Checkout\Cart;
  3. use Shopware\Core\Checkout\Cart\Error\ErrorCollection;
  4. use Shopware\Core\Framework\Log\Package;
  5. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  6. #[Package('checkout')]
  7. class Validator
  8. {
  9.     /**
  10.      * @internal
  11.      *
  12.      * @param CartValidatorInterface[] $validators
  13.      */
  14.     public function __construct(private readonly iterable $validators)
  15.     {
  16.     }
  17.     public function validate(Cart $cartSalesChannelContext $context): array
  18.     {
  19.         $errors = new ErrorCollection();
  20.         foreach ($this->validators as $validator) {
  21.             $validator->validate($cart$errors$context);
  22.         }
  23.         return array_values($errors->getElements());
  24.     }
  25. }