| 
				
			 | 
			
			
				@@ -8,7 +8,7 @@ use Muzich\CoreBundle\Managers\CommentsManager; 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				8
			 | 
			
			
				 class CommentController extends Controller 
			 | 
		
	
		
			
			| 
				9
			 | 
			
				9
			 | 
			
			
				 { 
			 | 
		
	
		
			
			| 
				10
			 | 
			
				10
			 | 
			
			
				    
			 | 
		
	
		
			
			| 
				11
			 | 
			
				
			 | 
			
			
				-  public function addAction($element_id) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				11
			 | 
			
			
				+  public function addAction($element_id, $token) 
			 | 
		
	
		
			
			| 
				12
			 | 
			
				12
			 | 
			
			
				   { 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				13
			 | 
			
			
				     if (($response = $this->mustBeConnected(true))) 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				14
			 | 
			
			
				     { 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -16,41 +16,151 @@ class CommentController extends Controller 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				16
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				17
			 | 
			
			
				      
			 | 
		
	
		
			
			| 
				18
			 | 
			
				18
			 | 
			
			
				     if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element') 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				
			 | 
			
			
				-      ->findOneById($element_id))) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token) 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				20
			 | 
			
			
				     { 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				
			 | 
			
			
				-      throw $this->createNotFoundException('Not found'); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				21
			 | 
			
			
				+      return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				22
			 | 
			
			
				+        'status' => 'error', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				23
			 | 
			
			
				+        'errors' => array('NotFound') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				24
			 | 
			
			
				+      )); 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				25
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				26
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				27
			 | 
			
			
				+    $length = strlen((($comment = $this->getRequest()->request->get('comment')))); 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				28
			 | 
			
			
				          
			 | 
		
	
		
			
			| 
				24
			 | 
			
				29
			 | 
			
			
				     // TODO: Faire un objet pour le formulaire ajout de commentaire 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				
			 | 
			
			
				-    if ( 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				
			 | 
			
			
				-      strlen((($comment = $this->getRequest()->request->get('comment')))) 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				
			 | 
			
			
				-      >= $this->container->getParameter('comment_add_min_length') 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				
			 | 
			
			
				-    ) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				30
			 | 
			
			
				+    if ($length  < $this->container->getParameter('comment_add_min_length')) 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				31
			 | 
			
			
				     { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				32
			 | 
			
			
				+      return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				33
			 | 
			
			
				+        'status' => 'error', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				34
			 | 
			
			
				+        'errors' => array($this->trans( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				+          'element.comments.add_error.min',  
			 | 
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				+          array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				+            '%limit%' => $this->container->getParameter('comment_add_min_length') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				+          ),  
			 | 
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				+          'elements' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				+        ) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				+      ))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				43
			 | 
			
			
				+    if ($length > $this->container->getParameter('comment_add_max_length')) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				+      return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+        'status' => 'error', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+        'errors' => array($this->trans( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+          'element.comments.add_error.max',  
			 | 
		
	
		
			
			| 
				
			 | 
			
				49
			 | 
			
			
				+          array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+            '%limit%' => $this->container->getParameter('comment_add_max_length') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+          ),  
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+          'elements' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+        ) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+      ))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				30
			 | 
			
				57
			 | 
			
			
				        
			 | 
		
	
		
			
			| 
				31
			 | 
			
				
			 | 
			
			
				-      // On met a jour les commentaires 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				
			 | 
			
			
				-      $cm = new CommentsManager($element->getComments()); 
			 | 
		
	
		
			
			| 
				33
			 | 
			
				
			 | 
			
			
				-      $cm->add($this->getUser(), $comment); 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				
			 | 
			
			
				-      $element->setComments($cm->get()); 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				
			 | 
			
			
				-       
			 | 
		
	
		
			
			| 
				36
			 | 
			
				
			 | 
			
			
				-      $this->getDoctrine()->getEntityManager()->persist($element); 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				
			 | 
			
			
				-      $this->getDoctrine()->getEntityManager()->flush(); 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				-       
			 | 
		
	
		
			
			| 
				39
			 | 
			
				
			 | 
			
			
				-      // On récupère le html du li avec le comment pour la réponse 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				
			 | 
			
			
				-      $html = $this->render('MuzichCommentBundle:Comment:comment.html.twig', array( 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				-        'comment'     => $cm->getLast() 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				
			 | 
			
			
				-      ))->getContent(); 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				
			 | 
			
			
				-       
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+    // On met a jour les commentaires 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+    $cm = new CommentsManager($element->getComments()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+    $cm->add($this->getUser(), $comment); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+    $element->setComments($cm->get()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				+    $this->getDoctrine()->getEntityManager()->persist($element); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+    $this->getDoctrine()->getEntityManager()->flush(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				65
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				66
			 | 
			
			
				+    // On récupère le html du li avec le comment pour la réponse 
			 | 
		
	
		
			
			| 
				
			 | 
			
				67
			 | 
			
			
				+    $html = $this->render('MuzichCommentBundle:Comment:li.comment.html.twig', array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				68
			 | 
			
			
				+      'comment'     => $cm->getLast(), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				69
			 | 
			
			
				+      'element_id'  => $element->getId() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				70
			 | 
			
			
				+    ))->getContent(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				71
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				72
			 | 
			
			
				+    return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				+      'status' => 'success', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+      'html'   => $html 
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+    )); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				+          
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+  } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+   
			 | 
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				+  public function deleteAction($element_id, $date, $token) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				+  { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+    if (($response = $this->mustBeConnected(true))) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+      return $response; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				+    if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				89
			 | 
			
			
				       return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				
			 | 
			
			
				-        'status' => 'success', 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				
			 | 
			
			
				-        'html'   => $html 
			 | 
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				+        'status' => 'error', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+        'errors' => array('NotFound') 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				92
			 | 
			
			
				       )); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				+    // On met a jour les commentaires 
			 | 
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				+    $cm = new CommentsManager($element->getComments()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				+    $cm->delete($this->getUserId(), $date); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				+    $element->setComments($cm->get()); 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				99
			 | 
			
			
				        
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+    $this->getDoctrine()->getEntityManager()->persist($element); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+    $this->getDoctrine()->getEntityManager()->flush(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+    return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				+      'status' => 'success' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+    )); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				106
			 | 
			
			
				+  } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				107
			 | 
			
			
				+   
			 | 
		
	
		
			
			| 
				
			 | 
			
				108
			 | 
			
			
				+  public function editAction($element_id, $date, $token) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				109
			 | 
			
			
				+  { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				110
			 | 
			
			
				+    if (($response = $this->mustBeConnected(true))) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				111
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				112
			 | 
			
			
				+      return $response; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				113
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				114
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				115
			 | 
			
			
				+    if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				116
			 | 
			
			
				+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				+      return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				119
			 | 
			
			
				+        'status' => 'error', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				120
			 | 
			
			
				+        'errors' => array('NotFound') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				121
			 | 
			
			
				+      )); 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				122
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				
			 | 
			
			
				-    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				123
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				124
			 | 
			
			
				+    $cm = new CommentsManager($element->getComments()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				125
			 | 
			
			
				+    $comment = $cm->get($cm->getIndex($this->getUserId(), $date)); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				126
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				127
			 | 
			
			
				+    $html = $this->render('MuzichCommentBundle:Comment:edit.html.twig', array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				128
			 | 
			
			
				+      'comment'     => $comment, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				129
			 | 
			
			
				+      'element_id'  => $element->getId(), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				130
			 | 
			
			
				+      'date'        => $date 
			 | 
		
	
		
			
			| 
				
			 | 
			
				131
			 | 
			
			
				+    ))->getContent(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				132
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				133
			 | 
			
			
				+    return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				134
			 | 
			
			
				+      'status' => 'success', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				135
			 | 
			
			
				+      'html'   => $html 
			 | 
		
	
		
			
			| 
				
			 | 
			
				136
			 | 
			
			
				+    )); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				137
			 | 
			
			
				+  } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				138
			 | 
			
			
				+   
			 | 
		
	
		
			
			| 
				
			 | 
			
				139
			 | 
			
			
				+  public function updateAction($element_id, $date, $token, $dom_id) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				140
			 | 
			
			
				+  { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				141
			 | 
			
			
				+    if (($response = $this->mustBeConnected(true))) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				142
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				143
			 | 
			
			
				+      return $response; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				144
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				145
			 | 
			
			
				+     
			 | 
		
	
		
			
			| 
				
			 | 
			
				146
			 | 
			
			
				+    if (!($element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				147
			 | 
			
			
				+      ->findOneById($element_id)) || $this->getUser()->getPersonalHash() != $token) 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				148
			 | 
			
			
				     { 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				149
			 | 
			
			
				       return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				150
			 | 
			
			
				         'status' => 'error', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				151
			 | 
			
			
				+        'errors' => array('NotFound') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				152
			 | 
			
			
				+      )); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				153
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				154
			 | 
			
			
				+         
			 | 
		
	
		
			
			| 
				
			 | 
			
				155
			 | 
			
			
				+    // TODO: Faire un objet pour le formulaire ajout de commentaire 
			 | 
		
	
		
			
			| 
				
			 | 
			
				156
			 | 
			
			
				+    $length = strlen((($comment = $this->getRequest()->request->get('comment')))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				157
			 | 
			
			
				+         
			 | 
		
	
		
			
			| 
				
			 | 
			
				158
			 | 
			
			
				+    // TODO: Faire un objet pour le formulaire ajout de commentaire 
			 | 
		
	
		
			
			| 
				
			 | 
			
				159
			 | 
			
			
				+    if ($length  < $this->container->getParameter('comment_add_min_length')) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				160
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				161
			 | 
			
			
				+      return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				162
			 | 
			
			
				+        'status' => 'error', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				163
			 | 
			
			
				+        'dom_id' => $dom_id, 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				164
			 | 
			
			
				         'errors' => array($this->trans( 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				165
			 | 
			
			
				           'element.comments.add_error.min',  
			 | 
		
	
		
			
			| 
				56
			 | 
			
				166
			 | 
			
			
				           array( 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -60,6 +170,40 @@ class CommentController extends Controller 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				170
			 | 
			
			
				         ) 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				171
			 | 
			
			
				       ))); 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				172
			 | 
			
			
				     } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				173
			 | 
			
			
				+    if ($length > $this->container->getParameter('comment_add_max_length')) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				174
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				175
			 | 
			
			
				+      return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				176
			 | 
			
			
				+        'status' => 'error', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				177
			 | 
			
			
				+        'dom_id' => $dom_id, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				178
			 | 
			
			
				+        'errors' => array($this->trans( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				179
			 | 
			
			
				+          'element.comments.add_error.max',  
			 | 
		
	
		
			
			| 
				
			 | 
			
				180
			 | 
			
			
				+          array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				181
			 | 
			
			
				+            '%limit%' => $this->container->getParameter('comment_add_max_length') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				182
			 | 
			
			
				+          ),  
			 | 
		
	
		
			
			| 
				
			 | 
			
				183
			 | 
			
			
				+          'elements' 
			 | 
		
	
		
			
			| 
				
			 | 
			
				184
			 | 
			
			
				+        ) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				185
			 | 
			
			
				+      ))); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				186
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				187
			 | 
			
			
				+       
			 | 
		
	
		
			
			| 
				
			 | 
			
				188
			 | 
			
			
				+    // On met a jour les commentaires 
			 | 
		
	
		
			
			| 
				
			 | 
			
				189
			 | 
			
			
				+    $cm = new CommentsManager($element->getComments()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				190
			 | 
			
			
				+    $cm->update($this->getUser(), $date, $comment); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				191
			 | 
			
			
				+    $element->setComments($cm->get()); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				192
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				193
			 | 
			
			
				+    $this->getDoctrine()->getEntityManager()->persist($element); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				194
			 | 
			
			
				+    $this->getDoctrine()->getEntityManager()->flush(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				195
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				196
			 | 
			
			
				+    // On récupère le html du li avec le comment pour la réponse 
			 | 
		
	
		
			
			| 
				
			 | 
			
				197
			 | 
			
			
				+    $html = $this->render('MuzichCommentBundle:Comment:comment.html.twig', array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				198
			 | 
			
			
				+      'comment'     => $cm->get($cm->getIndex($this->getUserId(), $date)), 
			 | 
		
	
		
			
			| 
				
			 | 
			
				199
			 | 
			
			
				+      'element_id'  => $element->getId() 
			 | 
		
	
		
			
			| 
				
			 | 
			
				200
			 | 
			
			
				+    ))->getContent(); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				201
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				202
			 | 
			
			
				+    return $this->jsonResponse(array( 
			 | 
		
	
		
			
			| 
				
			 | 
			
				203
			 | 
			
			
				+      'status' => 'success', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				204
			 | 
			
			
				+      'dom_id' => $dom_id, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				205
			 | 
			
			
				+      'html'   => $html 
			 | 
		
	
		
			
			| 
				
			 | 
			
				206
			 | 
			
			
				+    )); 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				207
			 | 
			
			
				      
			 | 
		
	
		
			
			| 
				64
			 | 
			
				208
			 | 
			
			
				   } 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				209
			 | 
			
			
				    
			 |