<?php | |||||
namespace Lc\ShopBundle\Context ; | |||||
interface DocumentUtilsInterface | |||||
{ | |||||
} |
$this->translator = $translator; | $this->translator = $translator; | ||||
} | } | ||||
public function createCustomForm($class, $action, $parameters, $data = true) | |||||
public function createCustomForm($class, $action, $parameters, $data = true, $options = array()) | |||||
{ | { | ||||
$options = array(); | |||||
if ($data) $options['data'] = $parameters['entity']; | if ($data) $options['data'] = $parameters['entity']; | ||||
$options['action'] = $this->generateUrl('easyadmin', array( | $options['action'] = $this->generateUrl('easyadmin', array( | ||||
'action' => $action, | 'action' => $action, |
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents") | * @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", mappedBy="documents") | ||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | */ | ||||
protected $orderShops; | protected $orderShops; | ||||
/** | /** | ||||
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"}) | * @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"}) | ||||
*/ | */ |
quantityProduct: Quantité (en rapport à l'unité) | quantityProduct: Quantité (en rapport à l'unité) | ||||
unit: Unité | unit: Unité | ||||
redeliverySupplierShort: Erreur producteur | redeliverySupplierShort: Erreur producteur | ||||
redeliverySupplier: Erreur producteur (Aura un prix à 0€ dans le prohain bon de commande producteur - vous devez cocher à recommander) | |||||
redeliverySupplierMistake: Erreur producteur (Aura un prix à 0€ dans le prohain bon de commande producteur - vous devez cocher à recommander) | |||||
redeliverySupplierOrderShort: À recommander au producteur | redeliverySupplierOrderShort: À recommander au producteur | ||||
redeliverySupplierOrder: À recommander au producteur (Sera affiché dans le prohain bon de commande producteur) | redeliverySupplierOrder: À recommander au producteur (Sera affiché dans le prohain bon de commande producteur) | ||||
deliveryType: Type de livraison | deliveryType: Type de livraison |
if(isset($params['merchant'])) { | if(isset($params['merchant'])) { | ||||
$document->setMerchant($params['merchant']) ; | $document->setMerchant($params['merchant']) ; | ||||
} | } | ||||
else { | |||||
elseif(isset($params['order_shops'])) { | |||||
$document->setMerchant($params['order_shops'][0]->getMerchant()) ; | $document->setMerchant($params['order_shops'][0]->getMerchant()) ; | ||||
} | } | ||||
foreach($params['order_shops'] as $orderShop) { | |||||
$document->addOrderShop($orderShop) ; | |||||
if(isset($params['order_shops'])) { | |||||
foreach ($params['order_shops'] as $orderShop) { | |||||
$document->addOrderShop($orderShop); | |||||
} | |||||
} | } | ||||
$document->setType($params['type']) ; | $document->setType($params['type']) ; |
<?php | <?php | ||||
namespace Lc\ShopBundle\Services\Price ; | |||||
namespace Lc\ShopBundle\Services\Price; | |||||
use Lc\ShopBundle\Context\OrderProductInterface; | use Lc\ShopBundle\Context\OrderProductInterface; | ||||
use Lc\ShopBundle\Context\OrderShopInterface; | use Lc\ShopBundle\Context\OrderShopInterface; | ||||
class PriceUtils implements PriceUtilsInterface | class PriceUtils implements PriceUtilsInterface | ||||
{ | { | ||||
protected $productPriceUtils ; | |||||
protected $orderProductPriceUtils ; | |||||
protected $orderShopPriceUtils ; | |||||
protected $productPriceUtils; | |||||
protected $orderProductPriceUtils; | |||||
protected $orderShopPriceUtils; | |||||
public function __construct(ProductPriceUtils $productPriceUtils, OrderProductPriceUtils $orderProductPriceUtils, OrderShopPriceUtilsInterface $orderShopPriceUtils) | public function __construct(ProductPriceUtils $productPriceUtils, OrderProductPriceUtils $orderProductPriceUtils, OrderShopPriceUtilsInterface $orderShopPriceUtils) | ||||
{ | { | ||||
$this->productPriceUtils = $productPriceUtils ; | |||||
$this->orderProductPriceUtils = $orderProductPriceUtils ; | |||||
$this->orderShopPriceUtils = $orderShopPriceUtils ; | |||||
$this->productPriceUtils = $productPriceUtils; | |||||
$this->orderProductPriceUtils = $orderProductPriceUtils; | |||||
$this->orderShopPriceUtils = $orderShopPriceUtils; | |||||
} | } | ||||
public function __call($name, $arguments) | public function __call($name, $arguments) | ||||
{ | { | ||||
$entity = $arguments[0] ; | |||||
$service = '' ; | |||||
if (strpos($name, 'apply') === false) { | |||||
$entity = $arguments[0]; | |||||
$service = ''; | |||||
if($entity instanceof ProductPropertyInterface) { | |||||
$service = 'productPriceUtils' ; | |||||
} | |||||
if($entity instanceof OrderProductInterface) { | |||||
$service = 'orderProductPriceUtils' ; | |||||
} | |||||
if($entity instanceof OrderShopInterface || is_array($entity)) { | |||||
$service = 'orderShopPriceUtils' ; | |||||
} | |||||
if(strlen($service) && $entity && method_exists($this->$service, $name)) { | |||||
if(isset($arguments[1]) && isset($arguments[2]) && isset($arguments[3])) { | |||||
return $this->$service->$name($entity, $arguments[1], $arguments[2], $arguments[3]) ; | |||||
} | |||||
elseif(isset($arguments[1]) && isset($arguments[2])) { | |||||
return $this->$service->$name($entity, $arguments[1], $arguments[2]) ; | |||||
} | |||||
elseif(isset($arguments[1])) { | |||||
return $this->$service->$name($entity, $arguments[1]) ; | |||||
if ($entity instanceof ProductPropertyInterface) { | |||||
$service = 'productPriceUtils'; | |||||
} | } | ||||
else { | |||||
return $this->$service->$name($entity) ; | |||||
if ($entity instanceof OrderProductInterface) { | |||||
$service = 'orderProductPriceUtils'; | |||||
} | } | ||||
} | |||||
else { | |||||
if(!strlen($service)) { | |||||
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré.") ; | |||||
if ($entity instanceof OrderShopInterface || is_array($entity)) { | |||||
$service = 'orderShopPriceUtils'; | |||||
} | } | ||||
else { | |||||
if(!method_exists($this->$service, $name)) { | |||||
throw new \ErrorException("PriceUtils : la méthode ".$name." du service ".$service." n'existe pas.") ; | |||||
if (strlen($service) && $entity && method_exists($this->$service, $name)) { | |||||
if (isset($arguments[1]) && isset($arguments[2]) && isset($arguments[3])) { | |||||
return $this->$service->$name($entity, $arguments[1], $arguments[2], $arguments[3]); | |||||
} elseif (isset($arguments[1]) && isset($arguments[2])) { | |||||
return $this->$service->$name($entity, $arguments[1], $arguments[2]); | |||||
} elseif (isset($arguments[1])) { | |||||
return $this->$service->$name($entity, $arguments[1]); | |||||
} else { | |||||
return $this->$service->$name($entity); | |||||
} | |||||
} else { | |||||
if (!strlen($service)) { | |||||
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré."); | |||||
} else { | |||||
if (!method_exists($this->$service, $name)) { | |||||
throw new \ErrorException("PriceUtils : la méthode " . $name . " du service " . $service . " n'existe pas."); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | |||||
return false ; | |||||
return false; | |||||
} | |||||
} | } | ||||
} | |||||
} |
namespace Lc\ShopBundle\Services ; | namespace Lc\ShopBundle\Services ; | ||||
use Lc\ShopBundle\Context\DeliveryUtilsInterface; | use Lc\ShopBundle\Context\DeliveryUtilsInterface; | ||||
use Lc\ShopBundle\Context\DocumentUtilsInterface; | |||||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | use Lc\ShopBundle\Context\MerchantUtilsInterface; | ||||
use Lc\ShopBundle\Context\OrderUtilsInterface; | use Lc\ShopBundle\Context\OrderUtilsInterface; | ||||
use Lc\ShopBundle\Context\PriceUtilsInterface; | use Lc\ShopBundle\Context\PriceUtilsInterface; | ||||
PriceUtilsInterface $priceUtils, | PriceUtilsInterface $priceUtils, | ||||
DeliveryUtilsInterface $deliveryUtils, | DeliveryUtilsInterface $deliveryUtils, | ||||
CreditUtils $creditUtils, | CreditUtils $creditUtils, | ||||
DocumentUtils $documentUtils, | |||||
DocumentUtilsInterface $documentUtils, | |||||
MailUtils $mailUtils, | MailUtils $mailUtils, | ||||
TicketUtils $ticketUtils, | TicketUtils $ticketUtils, | ||||
PointLocationUtils $pointLocationUtils, | PointLocationUtils $pointLocationUtils, | ||||
return $this->creditUtils ; | return $this->creditUtils ; | ||||
} | } | ||||
public function getDocumentUtils(): DocumentUtils | |||||
public function getDocumentUtils(): DocumentUtilsInterface | |||||
{ | { | ||||
return $this->documentUtils ; | return $this->documentUtils ; | ||||
} | } |