Advertisement
Lien_Gesbor

WholesaleRulesetQuantityStepRulesTrait.php

Mar 26th, 2021
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.54 KB | None | 0 0
  1. trait WholesaleRulesetQuantityStepRulesTrait
  2. {
  3.     /**
  4.      * @var Collection|WholesaleRuleQuantityStepInterface[]
  5.      * @psalm-var Collection<array-key, WholesaleRuleQuantityStepInterface>
  6.      */
  7.     protected $quantityStepRules;
  8.  
  9.     /**
  10.      * @var Collection|WholesaleRuleQuantityStepInterface[]
  11.      * @psalm-var Collection<array-key, WholesaleRuleQuantityStepInterface>
  12.      */
  13.     protected $quantityStepRulesByTaxon;
  14.  
  15.     /**
  16.      * @var Collection|WholesaleRuleQuantityStepInterface[]
  17.      * @psalm-var Collection<array-key, WholesaleRuleQuantityStepInterface>
  18.      */
  19.     protected $quantityStepRulesByProduct;
  20.  
  21.     /**
  22.      * @var Collection|WholesaleRuleQuantityStepInterface[]
  23.      * @psalm-var Collection<array-key, WholesaleRuleQuantityStepInterface>
  24.      */
  25.     protected $quantityStepRulesByProductVariant;
  26.  
  27.     public function initWholesaleRulesetQuantityStepStepRulesTrait()
  28.     {
  29.         $this->quantityStepRules = new ArrayCollection();
  30.         $this->quantityStepRulesByTaxon = new ArrayCollection();
  31.         $this->quantityStepRulesByProduct = new ArrayCollection();
  32.     }
  33.  
  34.     public function addQuantityStepRule(WholesaleRuleQuantityStepInterface $quantityStepRule): void
  35.     {
  36.         if ($this->quantityStepRules->contains($quantityStepRule)) {
  37.             return;
  38.         }
  39.         $quantityStepRule->setRuleset($this);
  40.         $this->quantityStepRules->add($quantityStepRule);
  41.     }
  42.  
  43.     public function removeQuantityStepRule(WholesaleRuleQuantityStepInterface $quantityStepRule): void
  44.     {
  45.         if (!$this->quantityStepRules->contains($quantityStepRule)) {
  46.             return;
  47.         }
  48.         $this->quantityStepRules->removeElement($quantityStepRule);
  49.     }
  50.  
  51.     public function hasQuantityStepRule(WholesaleRuleQuantityStepInterface $quantityStepRule): bool
  52.     {
  53.         return $this->quantityStepRules->contains($quantityStepRule);
  54.     }
  55.  
  56.     public function getQuantityStepRules(): Collection
  57.     {
  58.         return $this->quantityStepRules;
  59.     }
  60.  
  61.     public function getQuantityStepRulesByTaxon(): Collection
  62.     {
  63.         return $this->quantityStepRulesByTaxon;
  64.     }
  65.  
  66.     public function addQuantityStepRuleByTaxon(WholesaleRuleQuantityStepInterface $quantityStepRule): void
  67.     {
  68.         if ($this->quantityStepRulesByTaxon->contains($quantityStepRule)) {
  69.             return;
  70.         }
  71.         if ('Taxonomy' !== $quantityStepRule->getScope()) {
  72.             return;
  73.         }
  74.         $this->quantityStepRulesByTaxon->add($quantityStepRule);
  75.     }
  76.  
  77.     public function removeQuantityStepRuleByTaxon(WholesaleRuleQuantityStepInterface $quantityStepRule): void
  78.     {
  79.         if (!$this->quantityStepRulesByTaxon->contains($quantityStepRule)) {
  80.             return;
  81.         }
  82.         $this->quantityStepRulesByTaxon->removeElement($quantityStepRule);
  83.     }
  84.  
  85.     public function getQuantityStepRulesByProduct(): Collection
  86.     {
  87.         return $this->quantityStepRulesByProduct;
  88.     }
  89.  
  90.     public function addQuantityStepRuleByProduct(WholesaleRuleQuantityStepInterface $quantityStepRule): void
  91.     {
  92.         if ($this->quantityStepRulesByProduct->contains($quantityStepRule)) {
  93.             return;
  94.         }
  95.         if ('Product' !== $quantityStepRule->getScope()) {
  96.             return;
  97.         }
  98.         $this->quantityStepRulesByProduct->add($quantityStepRule);
  99.     }
  100.  
  101.     public function removeQuantityStepRuleByProduct(WholesaleRuleQuantityStepInterface $quantityStepRule): void
  102.     {
  103.         if (!$this->quantityStepRulesByProduct->contains($quantityStepRule)) {
  104.             return;
  105.         }
  106.         $this->quantityStepRulesByProduct->removeElement($quantityStepRule);
  107.     }
  108.  
  109.     public function getQuantityStepRulesByProductVariant(): ?Collection
  110.     {
  111.         return $this->quantityStepRulesByProductVariant;
  112.     }
  113.  
  114.     public function addQuantityStepRuleByProductVariant(WholesaleRuleQuantityStepInterface $quantityStepRule): void
  115.     {
  116.         if ($this->quantityStepRulesByProductVariant->contains($quantityStepRule)) {
  117.             return;
  118.         }
  119.         if ('Product Variant' !== $quantityStepRule->getScope()) {
  120.             return;
  121.         }
  122.         $this->quantityStepRulesByProductVariant->add($quantityStepRule);
  123.     }
  124.  
  125.     public function removeQuantityStepRuleByProductVariant(WholesaleRuleQuantityStepInterface $quantityStepRule): void
  126.     {
  127.         if (!$this->quantityStepRulesByProductVariant->contains($quantityStepRule)) {
  128.             return;
  129.         }
  130.         $this->quantityStepRulesByProductVariant->removeElement($quantityStepRule);
  131.     }
  132. }
  133.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement