|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
-
- namespace domain\Product\ProductPrice\Service;
-
- use domain\PointSale\PointSale\PointSale;
- use domain\Product\Product\Product;
- use domain\Product\ProductPrice\Model\ProductPrice;
- use domain\User\User\User;
- use domain\User\UserGroup\UserGroup;
- use domain\_\AbstractBuilder;
-
- class ProductPriceBuilder extends AbstractBuilder
- {
- public function instanciateProductPrice(
- Product $product,
- float $price,
- User $user = null,
- UserGroup $userGroup = null,
- PointSale $pointSale = null,
- float $quantityFrom = null): ProductPrice
- {
- $productPrice = new ProductPrice();
-
- $productPrice->populateProduct($product);
- $productPrice->price = $price;
-
- if($user) {
- $productPrice->populateUser($user);
- }
-
- if($userGroup) {
- $productPrice->populateUserGroup($userGroup);
- }
-
- if($pointSale) {
- $productPrice->populatePointSale($pointSale);
- }
-
- if($quantityFrom) {
- $productPrice->quantity_from = $quantityFrom;
- }
-
- return $productPrice;
- }
-
- public function createProductPrice(): ProductPrice
- {
- $productPrice = $this->instanciateProductPrice();
- $this->saveCreate($productPrice);
-
- return $productPrice;
- }
- }
|