/**
  * MAIN PAGE
  * 
  * If {code} exist, show it and allow modify/delete.
  * If {code} doesnt exist, allow to create a new container with code used.
  *
  * @Route("/{code}",defaults={"action"=null}, name="container_mobile_container")
  * @Route("/{code}/{action}", name="container_mobile_container_updated")
  * @Method("GET")
  * @Template("CBWarehouseBundle:Mobile:Container/container.html.twig")
  */
 public function showAction($code, $action)
 {
     $em = $this->getDoctrine()->getManager();
     $entity = $em->getRepository('CBWarehouseBundle:Container')->findOneBy(array('code' => $code));
     if ($entity) {
         $stock = $em->getRepository('CBWarehouseBundle:Stock')->findStockByContainer($entity->getId());
         $editForm = $this->createEditForm($entity);
         $deleteForm = $this->createDeleteForm($entity->getId());
         return array('entity' => $entity, 'form' => $editForm->createView(), 'delete_form' => $deleteForm->createView(), 'action' => $action, 'stock' => $stock, 'containerId' => $entity->getId());
     } else {
         $entity = new Container();
         $entity->setCode($code);
         $form = $this->createCreateForm($entity);
         return array('entity' => $entity, 'form' => $form->createView(), 'action' => 'new');
     }
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $cont1 = new Container();
     $cont1->setCode('000000000000000001');
     $cont1->setContainerType($this->getReference('containertype_europallet'));
     $cont1->setCreatedDate(new \DateTime());
     $cont1->setLocation($this->getReference('location_pulrec'));
     $manager->persist($cont1);
     $manager->flush();
     $this->addReference('container_cont1', $cont1);
 }