| author | cavaliet |
| Mon, 07 Jul 2014 17:23:47 +0200 | |
| changeset 122 | d672f7dd74dc |
| parent 17 | a16b5806e3f0 |
| permissions | -rwxr-xr-x |
| 9 | 1 |
<?php |
2 |
||
3 |
namespace Company\BaseBundle\Controller; |
|
4 |
||
5 |
use Company\BaseBundle\Entity\Document; |
|
6 |
use IRI\Bundle\WikiTagBundle\Entity\Document as BaseDocument; |
|
7 |
||
8 |
use Symfony\Component\HttpFoundation\Request; |
|
9 |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
|
10 |
||
11 |
||
12 |
class IndexController extends Controller |
|
13 |
{ |
|
14 |
||
15 |
public function indexAction() |
|
16 |
{ |
|
17 |
return $this->render('CompanyBaseBundle:Index:index.html.twig'); |
|
18 |
} |
|
19 |
||
20 |
public function otherAction() |
|
21 |
{ |
|
|
17
a16b5806e3f0
Little modification to enable routing from tag list.
cavaliet
parents:
13
diff
changeset
|
22 |
$tag_id = $this->getRequest()->query->get('tag'); |
|
a16b5806e3f0
Little modification to enable routing from tag list.
cavaliet
parents:
13
diff
changeset
|
23 |
return $this->render('CompanyBaseBundle:Index:other_page.html.twig', array('tag_id' => $tag_id)); |
| 9 | 24 |
} |
25 |
||
26 |
||
27 |
public function addDocumentAction(Request $request) |
|
28 |
{ |
|
29 |
$doc = new Document(); |
|
30 |
||
31 |
$form = $this->createFormBuilder($doc) |
|
32 |
->add('title', 'text') |
|
33 |
->add('description', 'textarea', array("required" => false,)) |
|
34 |
->getForm(); |
|
35 |
||
36 |
if ($request->getMethod() == 'POST') { |
|
37 |
$form->bindRequest($request); |
|
38 |
if ($form->isValid()) { |
|
39 |
$doc = $form->getData(); |
|
40 |
$em = $this->getDoctrine()->getEntityManager(); |
|
41 |
$em->persist($doc); |
|
42 |
$em->flush(); |
|
43 |
return $this->redirect($this->generateUrl('all_documents')); |
|
44 |
} |
|
45 |
} |
|
46 |
else{ |
|
47 |
return $this->render('CompanyBaseBundle:Index:add_document.html.twig', array('form' => $form->createView())); |
|
48 |
} |
|
49 |
} |
|
50 |
||
51 |
||
52 |
public function allDocumentsAction() |
|
53 |
{ |
|
54 |
$rep_docs = $this->getDoctrine()->getRepository('CompanyBaseBundle:Document'); |
|
55 |
$documents = $rep_docs->findAll(); |
|
56 |
||
57 |
return $this->render('CompanyBaseBundle:Index:all_documents.html.twig', array('documents' => $documents)); |
|
58 |
} |
|
59 |
||
60 |
||
61 |
public function allDocumentsPartialAction($param="") |
|
62 |
{ |
|
63 |
$rep_docs = $this->getDoctrine()->getRepository('CompanyBaseBundle:Document'); |
|
64 |
$documents = $rep_docs->findAll(); |
|
65 |
||
66 |
return $this->render('CompanyBaseBundle:Index:all_documents_partial.html.twig', array('documents' => $documents, 'param' => $param)); |
|
67 |
} |
|
68 |
||
69 |
/** |
|
70 |
* Template with tag management |
|
71 |
* |
|
72 |
*/ |
|
73 |
public function documentWithTagAction($idDoc) |
|
74 |
{ |
|
75 |
$rep_docs = $this->getDoctrine()->getRepository('CompanyBaseBundle:Document'); |
|
76 |
$doc = $rep_docs->findOneById($idDoc); |
|
77 |
return $this->render('CompanyBaseBundle:Index:tag_embedder.html.twig', array('doc' => $doc)); |
|
78 |
} |
|
79 |
||
| 13 | 80 |
/** |
81 |
* Template with the list of all tags |
|
82 |
* |
|
83 |
*/ |
|
84 |
public function allTagsAction() |
|
85 |
{ |
|
86 |
return $this->render('CompanyBaseBundle:Index:taglist_embedder.html.twig'); |
|
87 |
} |
|
88 |
||
| 9 | 89 |
} |