src/ViewProcessor/OrderViewProcessor.php line 62

Open in your IDE?
  1. <?php
  2. namespace App\ViewProcessor;
  3. use App\Entity\{ OrderPickupDeliveryOrderOptionsCustomerOptionsOrderEmployee };
  4. use Boldr\Shop\ShopBundle\Presenter\Order\{ OrderViewOrderViewProcessorInterface };
  5. use Boldr\Shop\ShopBundle\Entity\Order;
  6. use Boldr\Shop\ShopBundle\Presenter\Customer\{ AddressFormatterCustomerView };
  7. use Doctrine\ORM\EntityManagerInterface;
  8. class OrderViewProcessor implements OrderViewProcessorInterface
  9. {
  10.     private EntityManagerInterface $em;
  11.     private AddressFormatter $addressFormatter;
  12.     public function __construct(EntityManagerInterface $emAddressFormatter $addressFormatter)
  13.     {
  14.         $this->em $em;
  15.         $this->addressFormatter $addressFormatter;
  16.     }
  17.     public function processOrderView(OrderView $orderViewOrder $orderstring $locale): OrderView
  18.     {
  19.         // @TODO 2.x Move into a decorator
  20.         $pickupDelivery $order->getId() === null null $this->em->getRepository(OrderPickupDelivery::class)->find($order);
  21.         $orderOptions $order->getId() === null null $this->em->getRepository(OrderOptions::class)->find($order);
  22.         $customerOptions $order->getCustomer()->getId() === null null $this->em->getRepository(CustomerOptions::class)->find($order->getCustomer());
  23.         $orderView->gesnedenInDoos $orderOptions === null false $orderOptions->getGesnedenInDoos();
  24.         if ($order->getId())
  25.         {
  26.             $orderEmployee $this->em->getRepository(OrderEmployee::class)->find($order);
  27.             if ($orderEmployee)
  28.             {
  29.                 $customerView = new CustomerView(
  30.                     $order->getCustomer()->getId(),
  31.                     $orderEmployee->getName(),
  32.                     $orderEmployee->getDepartment() ? '('$orderEmployee->getDepartment() .')' '',
  33.                     $orderEmployee->getEmailAddress(),
  34.                     $order->getCustomer()->getPhoneNumber(),
  35.                     $order->getCustomer()->getCompany(),
  36.                     false,
  37.                     $order->getCustomer()->getLocale()
  38.                 );
  39.                 $orderView->setCustomer($customerView);
  40.             }
  41.         }
  42.         if ($pickupDelivery)
  43.         {
  44.             $orderView->delivery $pickupDelivery->getDelivery();
  45.             $orderView->deliveryAddress $pickupDelivery->getAddress() ? $this->addressFormatter->formatAddress($pickupDelivery->getAddress()) : null;
  46.             $orderView->pickupDeliveryDateTime $pickupDelivery->getDateTime();
  47.             $orderView->rit $customerOptions === null false $customerOptions->getRit();
  48.         }
  49.         else
  50.         {
  51.             $orderView->delivery null;
  52.             $orderView->deliveryAddress null;
  53.             $orderView->pickupDeliveryDateTime null;
  54.         }
  55.         return $orderView;
  56.     }
  57. }