/**
  * @Route("/dispatch", name="dispatch")
  * @return JsonResponse
  */
 public function dispatchAction()
 {
     $orders = $this->get('doctrine_mongodb')->getRepository('AppBundle:Order')->findBy(['state' => Order::TO_BE_DISPATCHED]);
     foreach ($orders as $order) {
         $order->status = Order::DISPATCHED;
         Email::orderDispatched($order);
         $this->get('doctrine_mongodb')->getManager()->persist($order);
     }
     $this->get('doctrine_mongodb')->getManager()->flush();
     return new JsonResponse([]);
 }
 /**
  * @param $order
  */
 public static function orderWaitingStock($order)
 {
     $message = $order->quantity . ' of ' . $order->title . ' not available right now.';
     Email::send($order->clientName, $order->email, 'Waiting for stock', $message);
 }