/** * Edit and Saves order * * @param OrderInterface $order Order * * @return array Data * * @Route( * path = "/{id}", * name = "admin_order_edit", * requirements = { * "id" = "\d+", * }, * methods = {"GET"} * ) * @Template * * @EntityAnnotation( * class = "elcodi.entity.order.class", * name = "order", * mapping = { * "id" = "~id~" * } * ) */ public function editAction(OrderInterface $order) { $nextPaymentTransitions = $this->get('elcodi.order.payment_states_machine')->getAvailableStates($order->getPaymentStateLineStack()->getLastStateLine()->getName()); $nextShippingTransitions = $this->get('elcodi.order.shipping_states_machine')->getAvailableStates($order->getShippingStateLineStack()->getLastStateLine()->getName()); $allStates = array_merge($order->getPaymentStateLineStack()->getStateLines()->toArray(), $order->getShippingStateLineStack()->getStateLines()->toArray()); usort($allStates, function (StateLineInterface $a, StateLineInterface $b) { return $a->getCreatedAt() == $b->getCreatedAt() ? $a->getId() > $b->getId() : $a->getCreatedAt() > $b->getCreatedAt(); }); $addressFormatter = $this->get('elcodi.formatter.address'); $deliveryAddress = $order->getDeliveryAddress(); $deliveryInfo = $addressFormatter->toArray($deliveryAddress); $billingAddress = $order->getBillingAddress(); $billingInfo = $addressFormatter->toArray($billingAddress); return ['order' => $order, 'nextPaymentTransitions' => $nextPaymentTransitions, 'nextShippingTransitions' => $nextShippingTransitions, 'allStates' => $allStates, 'deliveryInfo' => $deliveryInfo, 'billingInfo' => $billingInfo]; }