/**
  * Retrieves invoice with id $id or throws an exception if it doesn't exist.
  *
  * @param $id
  *
  * @return InvoiceInterface
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 protected function getInvoice($id)
 {
     $invoice = $this->invoiceManager->findOneBy(array('id' => $id));
     if (null === $invoice) {
         throw new NotFoundHttpException(sprintf('Invoice (%d) not found', $id));
     }
     return $invoice;
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 protected function configureSideMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
 {
     if (!$childAdmin && !in_array($action, array('edit'))) {
         return;
     }
     $admin = $this->isChild() ? $this->getParent() : $this;
     $id = $admin->getRequest()->get('id');
     $menu->addChild($this->trans('sonata.order.sidemenu.link_order_edit', array(), 'SonataOrderBundle'), array('uri' => $admin->generateUrl('edit', array('id' => $id))));
     $menu->addChild($this->trans('sonata.order.sidemenu.link_order_elements_list', array(), 'SonataOrderBundle'), array('uri' => $admin->generateUrl('sonata.order.admin.order_element.list', array('id' => $id))));
     $order = $this->orderManager->findOneBy(array('id' => $id));
     $invoice = $this->invoiceManager->findOneBy(array('reference' => $order->getReference()));
     if (null === $invoice) {
         $menu->addChild($this->trans('sonata.order.sidemenu.link_order_invoice_generate', array(), 'SonataOrderBundle'), array('uri' => $admin->generateUrl('generateInvoice', array('id' => $id))));
     } else {
         $menu->addChild($this->trans('sonata.order.sidemenu.link_order_invoice_edit', array(), 'SonataOrderBundle'), array('uri' => $admin->getRouteGenerator()->generate('admin_sonata_invoice_invoice_edit', array('id' => $invoice->getId()))));
     }
 }