選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

PriceUtils.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. return $this->$service->$name($entity) ;
  34. }
  35. return false ;
  36. }
  37. }