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.

PriceUtils.php 2.3KB

4 년 전
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Lc\ShopBundle\Services\Price ;
  3. use Lc\ShopBundle\Context\OrderProductInterface;
  4. use Lc\ShopBundle\Context\OrderShopInterface;
  5. use Lc\ShopBundle\Context\OrderShopPriceUtilsInterface;
  6. use Lc\ShopBundle\Context\PriceUtilsInterface;
  7. use Lc\ShopBundle\Context\ProductPropertyInterface;
  8. class PriceUtils implements PriceUtilsInterface
  9. {
  10. protected $productPriceUtils ;
  11. protected $orderProductPriceUtils ;
  12. protected $orderShopPriceUtils ;
  13. public function __construct(ProductPriceUtils $productPriceUtils, OrderProductPriceUtils $orderProductPriceUtils, OrderShopPriceUtilsInterface $orderShopPriceUtils)
  14. {
  15. $this->productPriceUtils = $productPriceUtils ;
  16. $this->orderProductPriceUtils = $orderProductPriceUtils ;
  17. $this->orderShopPriceUtils = $orderShopPriceUtils ;
  18. }
  19. public function __call($name, $arguments)
  20. {
  21. $entity = $arguments[0] ;
  22. $service = '' ;
  23. if($entity instanceof ProductPropertyInterface) {
  24. $service = 'productPriceUtils' ;
  25. }
  26. if($entity instanceof OrderProductInterface) {
  27. $service = 'orderProductPriceUtils' ;
  28. }
  29. if($entity instanceof OrderShopInterface) {
  30. $service = 'orderShopPriceUtils' ;
  31. }
  32. if(strlen($service) && $entity && method_exists($this->$service, $name)) {
  33. if(isset($arguments[1]) && isset($arguments[2]) && isset($arguments[3])) {
  34. return $this->$service->$name($entity, $arguments[1], $arguments[2], $arguments[3]) ;
  35. }
  36. elseif(isset($arguments[1]) && isset($arguments[2])) {
  37. return $this->$service->$name($entity, $arguments[1], $arguments[2]) ;
  38. }
  39. elseif(isset($arguments[1])) {
  40. return $this->$service->$name($entity, $arguments[1]) ;
  41. }
  42. else {
  43. return $this->$service->$name($entity) ;
  44. }
  45. }
  46. return false ;
  47. }
  48. }