/** * Build and persist a box. * * @param string $hostname * @param PLN $network * @param ObjectManager $manager * * @return Box */ private function buildBox($hostname, $network, ObjectManager $manager) { $box = new Box(); $box->setHostName($hostname); $box->setPln($this->getReference($network)); $manager->persist($box); return $box; }
/** * Displays a form to create a new box entity, which is linked to a PLN. * Requires *both* ROLE_LOMADMIN and PLNADMIN on the PLN. * * @param int $id the network id * * @return Response A Response instance */ public function newBoxAction($id) { $this->get('lom.access')->checkAccess("ROLE_LOMADMIN"); $em = $this->getDoctrine()->getManager(); $pln = $em->getRepository('LOMCrudBundle:Pln')->find($id); if (!$pln) { throw $this->createNotFoundException('Unable to find Pln entity.'); } $this->get('lom.access')->checkAccess("PLNADMIN", $pln); $box = new Box(); $box->setPln($pln); $form = $this->createBoxCreateForm($box); return $this->render('LOMCrudBundle:Pln:newbox.html.twig', array('box' => $box, 'pln' => $pln, 'newbox_form' => $form->createView())); }