You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ProductPriceBuilder.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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->quantity_from = $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. }