Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

53 rindas
1.3KB

  1. <?php
  2. namespace domain\Product\ProductPrice\Service;
  3. use domain\PointSale\PointSale\PointSale;
  4. use domain\Product\Product\Product;
  5. use domain\Product\ProductPrice\Model\ProductPrice;
  6. use domain\User\User\User;
  7. use domain\User\UserGroup\UserGroup;
  8. use domain\_\AbstractBuilder;
  9. class ProductPriceBuilder extends AbstractBuilder
  10. {
  11. public function instanciateProductPrice(
  12. Product $product,
  13. float $price,
  14. User $user = null,
  15. UserGroup $userGroup = null,
  16. PointSale $pointSale = null,
  17. float $quantityFrom = null): ProductPrice
  18. {
  19. $productPrice = new ProductPrice();
  20. $productPrice->populateProduct($product);
  21. $productPrice->price = $price;
  22. if($user) {
  23. $productPrice->populateUser($user);
  24. }
  25. if($userGroup) {
  26. $productPrice->populateUserGroup($userGroup);
  27. }
  28. if($pointSale) {
  29. $productPrice->populatePointSale($pointSale);
  30. }
  31. if($quantityFrom) {
  32. $productPrice->from_quantity = $quantityFrom;
  33. }
  34. return $productPrice;
  35. }
  36. public function createProductPrice(): ProductPrice
  37. {
  38. $productPrice = $this->instanciateProductPrice();
  39. $this->saveCreate($productPrice);
  40. return $productPrice;
  41. }
  42. }