コード例 #1
0
 /**
  * Displays a form to create a new Contract entity.
  *
  * @Template()
  * @Secure(roles="ROLE_USER")
  */
 public function newAction(Door $door)
 {
     $entity = new Contract();
     if (!empty($door)) {
         $entity->setDoor($door);
         $entity->setTrustee($door->getSite()->getTrustee());
     }
     $entity->setBegin(new \DateTime());
     $form = $this->createForm(new ContractType(), $entity);
     return array('entity' => $entity, 'form' => $form->createView());
 }
コード例 #2
0
 /**
  * Finds and displays a Door entity.
  *
  * @Template()
  * @Secure(roles="ROLE_USER")
  */
 public function showAction(Door $entity)
 {
     $em = $this->getDoctrine()->getManager();
     $contracts = $em->getRepository('JLMContractBundle:Contract')->findByDoor($entity, array('begin' => 'DESC'));
     // Modal nouveau contrat
     $contractNew = new Contract();
     $contractNew->setDoor($entity);
     $contractNew->setTrustee($entity->getSite()->getTrustee());
     $contractNew->setBegin(new \DateTime());
     $form_contractNew = $this->createForm(new ContractType(), $contractNew);
     // Formulaires d'edition des contrat
     $form_contractEdits = $form_contractStops = array();
     foreach ($contracts as $contract) {
         $form_contractEdits[] = $this->get('form.factory')->createNamed('contractEdit' . $contract->getId(), new ContractType(), $contract)->createView();
         $form_contractStops[] = $this->get('form.factory')->createNamed('contractStop' . $contract->getId(), new ContractStopType(), $contract)->createView();
     }
     return array('entity' => $entity, 'contracts' => $contracts, 'form_contractNew' => $form_contractNew->createView(), 'form_contractEdits' => $form_contractEdits, 'form_contractStops' => $form_contractStops);
 }