当前位置: 首页>>代码示例>>PHP>>正文


PHP PromotionInterface::getRules方法代码示例

本文整理汇总了PHP中Sylius\Component\Promotion\Model\PromotionInterface::getRules方法的典型用法代码示例。如果您正苦于以下问题:PHP PromotionInterface::getRules方法的具体用法?PHP PromotionInterface::getRules怎么用?PHP PromotionInterface::getRules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sylius\Component\Promotion\Model\PromotionInterface的用法示例。


在下文中一共展示了PromotionInterface::getRules方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isEligible

 /**
  * {@inheritdoc}
  */
 public function isEligible(PromotionSubjectInterface $promotionSubject, PromotionInterface $promotion)
 {
     if (!$promotion->hasRules()) {
         return true;
     }
     foreach ($promotion->getRules() as $rule) {
         if (!$this->isEligibleToRule($promotionSubject, $rule)) {
             return false;
         }
     }
     return true;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:15,代码来源:RulesEligibilityChecker.php

示例2:

 function it_does_not_check_more_rules_if_one_has_returned_false(RuleCheckerInterface $cartQuantityRuleChecker, RuleCheckerInterface $itemTotalRuleChecker, RuleInterface $cartQuantityRule, RuleInterface $itemTotalRule, PromotionInterface $promotion, PromotionSubjectInterface $subject, ServiceRegistryInterface $rulesRegistry)
 {
     $promotion->hasRules()->willReturn(true);
     $promotion->getRules()->willReturn([$cartQuantityRule, $itemTotalRule]);
     $cartQuantityRule->getType()->willReturn(RuleInterface::TYPE_CART_QUANTITY);
     $cartQuantityRule->getConfiguration()->willReturn([]);
     $itemTotalRule->getType()->willReturn(RuleInterface::TYPE_ITEM_TOTAL);
     $itemTotalRule->getConfiguration()->willReturn([]);
     $rulesRegistry->get(RuleInterface::TYPE_CART_QUANTITY)->willReturn($cartQuantityRuleChecker);
     $rulesRegistry->get(RuleInterface::TYPE_ITEM_TOTAL)->willReturn($itemTotalRuleChecker);
     $cartQuantityRuleChecker->isEligible($subject, [])->willReturn(false);
     $itemTotalRuleChecker->isEligible($subject, [])->shouldNotBeCalled();
     $this->isEligible($subject, $promotion)->shouldReturn(false);
 }
开发者ID:ahmadrabie,项目名称:Sylius,代码行数:14,代码来源:RulesEligibilityCheckerSpec.php

示例3:

 function it_does_not_check_more_rules_if_one_has_returned_false(ServiceRegistryInterface $rulesRegistry, RuleCheckerInterface $firstRuleChecker, RuleCheckerInterface $secondRuleChecker, RuleInterface $firstRule, RuleInterface $secondRule, PromotionInterface $promotion, PromotionSubjectInterface $subject)
 {
     $promotion->hasRules()->willReturn(true);
     $promotion->getRules()->willReturn([$firstRule, $secondRule]);
     $firstRule->getType()->willReturn('first_rule');
     $firstRule->getConfiguration()->willReturn([]);
     $secondRule->getType()->willReturn('second_rule');
     $secondRule->getConfiguration()->willReturn([]);
     $rulesRegistry->get('first_rule')->willReturn($firstRuleChecker);
     $rulesRegistry->get('second_rule')->willReturn($secondRuleChecker);
     $firstRuleChecker->isEligible($subject, [])->willReturn(false);
     $secondRuleChecker->isEligible($subject, [])->shouldNotBeCalled();
     $this->isEligible($subject, $promotion)->shouldReturn(false);
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:14,代码来源:RulesEligibilityCheckerSpec.php

示例4: array

 function it_recognizes_subject_as_not_eligible_if_any_checker_recognize_it_as_not_eligible_even_when_coupon_matches($registry, RuleCheckerInterface $checker, PromotionCouponsAwareSubjectInterface $subject, PromotionInterface $promotion, CouponInterface $coupon, RuleInterface $rule)
 {
     $promotion->getStartsAt()->willReturn(null);
     $promotion->getEndsAt()->willReturn(null);
     $promotion->getUsageLimit()->willReturn(null);
     $promotion->hasRules()->willReturn(true);
     $registry->get(RuleInterface::TYPE_ITEM_TOTAL)->willReturn($checker);
     $promotion->getRules()->willReturn(array($rule));
     $promotion->isCouponBased()->willReturn(true);
     $rule->getType()->willReturn(RuleInterface::TYPE_ITEM_TOTAL);
     $rule->getConfiguration()->willReturn(array());
     $registry->get(RuleInterface::TYPE_ITEM_TOTAL)->willReturn($checker);
     $checker->isEligible($subject, array())->willReturn(false);
     $subject->getPromotionCoupons()->willReturn(array($coupon));
     $coupon->getPromotion()->willReturn($promotion);
     $this->isEligible($subject, $promotion)->shouldReturn(false);
 }
开发者ID:gaetzone,项目名称:Sylius,代码行数:17,代码来源:PromotionEligibilityCheckerSpec.php


注:本文中的Sylius\Component\Promotion\Model\PromotionInterface::getRules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。