diff -r 36080db2864e -r 6e8bd1081c8a src/Company/BaseBundle/Controller/IndexController.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Company/BaseBundle/Controller/IndexController.php Mon Oct 17 18:42:56 2011 +0200 @@ -0,0 +1,79 @@ +render('CompanyBaseBundle:Index:index.html.twig'); + } + + public function otherAction() + { + return $this->render('CompanyBaseBundle:Index:other_page.html.twig'); + } + + + public function addDocumentAction(Request $request) + { + $doc = new Document(); + + $form = $this->createFormBuilder($doc) + ->add('title', 'text') + ->add('description', 'textarea', array("required" => false,)) + ->getForm(); + + if ($request->getMethod() == 'POST') { + $form->bindRequest($request); + if ($form->isValid()) { + $doc = $form->getData(); + $em = $this->getDoctrine()->getEntityManager(); + $em->persist($doc); + $em->flush(); + return $this->redirect($this->generateUrl('all_documents')); + } + } + else{ + return $this->render('CompanyBaseBundle:Index:add_document.html.twig', array('form' => $form->createView())); + } + } + + + public function allDocumentsAction() + { + $rep_docs = $this->getDoctrine()->getRepository('CompanyBaseBundle:Document'); + $documents = $rep_docs->findAll(); + + return $this->render('CompanyBaseBundle:Index:all_documents.html.twig', array('documents' => $documents)); + } + + + public function allDocumentsPartialAction($param="") + { + $rep_docs = $this->getDoctrine()->getRepository('CompanyBaseBundle:Document'); + $documents = $rep_docs->findAll(); + + return $this->render('CompanyBaseBundle:Index:all_documents_partial.html.twig', array('documents' => $documents, 'param' => $param)); + } + + /** + * Template with tag management + * + */ + public function documentWithTagAction($idDoc) + { + $rep_docs = $this->getDoctrine()->getRepository('CompanyBaseBundle:Document'); + $doc = $rep_docs->findOneById($idDoc); + return $this->render('CompanyBaseBundle:Index:tag_embedder.html.twig', array('doc' => $doc)); + } + +}