vendor/shopware/core/Checkout/Cart/LineItem/Group/RulesMatcher/AnyRuleMatcher.php line 12

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Checkout\Cart\LineItem\Group\RulesMatcher;
  3. use Shopware\Core\Checkout\Cart\LineItem\Group\LineItemGroupDefinition;
  4. use Shopware\Core\Checkout\Cart\LineItem\Group\LineItemGroupRuleMatcherInterface;
  5. use Shopware\Core\Checkout\Cart\LineItem\LineItemFlatCollection;
  6. use Shopware\Core\Framework\Log\Package;
  7. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  8. #[Package('checkout')]
  9. class AnyRuleMatcher implements LineItemGroupRuleMatcherInterface
  10. {
  11.     private AbstractAnyRuleLineItemMatcher $anyRuleProvider;
  12.     /**
  13.      * @internal
  14.      */
  15.     public function __construct(AbstractAnyRuleLineItemMatcher $anyRuleProvider)
  16.     {
  17.         $this->anyRuleProvider $anyRuleProvider;
  18.     }
  19.     public function getMatchingItems(
  20.         LineItemGroupDefinition $groupDefinition,
  21.         LineItemFlatCollection $items,
  22.         SalesChannelContext $context
  23.     ): LineItemFlatCollection {
  24.         $matchingItems = [];
  25.         foreach ($items as $item) {
  26.             if ($this->anyRuleProvider->isMatching($groupDefinition$item$context)) {
  27.                 $matchingItems[] = $item;
  28.             }
  29.         }
  30.         return new LineItemFlatCollection($matchingItems);
  31.     }
  32. }