|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
-
- namespace Lc\ShopBundle\Services\Price ;
-
- use Lc\ShopBundle\Context\OrderProductInterface;
- use Lc\ShopBundle\Context\OrderShopInterface;
- use Lc\ShopBundle\Context\OrderShopPriceUtilsInterface;
- use Lc\ShopBundle\Context\PriceUtilsInterface;
- use Lc\ShopBundle\Context\ProductPropertyInterface;
-
- class PriceUtils implements PriceUtilsInterface
- {
- protected $productPriceUtils ;
- protected $orderProductPriceUtils ;
- protected $orderShopPriceUtils ;
-
- public function __construct(ProductPriceUtils $productPriceUtils, OrderProductPriceUtils $orderProductPriceUtils, OrderShopPriceUtilsInterface $orderShopPriceUtils)
- {
- $this->productPriceUtils = $productPriceUtils ;
- $this->orderProductPriceUtils = $orderProductPriceUtils ;
- $this->orderShopPriceUtils = $orderShopPriceUtils ;
- }
-
- public function __call($name, $arguments)
- {
- $entity = $arguments[0] ;
- $service = '' ;
-
- if($entity instanceof ProductPropertyInterface) {
- $service = 'productPriceUtils' ;
- }
-
- if($entity instanceof OrderProductInterface) {
- $service = 'orderProductPriceUtils' ;
- }
-
- if($entity instanceof OrderShopInterface) {
- $service = 'orderShopPriceUtils' ;
- }
-
- if(strlen($service) && $entity && method_exists($this->$service, $name)) {
- return $this->$service->$name($entity) ;
- }
-
- return false ;
- }
- }
|