@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | /** |
62 | 62 | * @param $params |
63 | - * @param $request |
|
63 | + * @param Request $request |
|
64 | 64 | * @param $comment_class |
65 | 65 | * @return Response |
66 | 66 | */ |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * Return a template |
99 | 99 | * @param $comment |
100 | 100 | * @param $request |
101 | - * @param $max_depth |
|
101 | + * @param boolean $max_depth |
|
102 | 102 | * @return string |
103 | 103 | */ |
104 | 104 | private function renderResponse($comment,$request,$max_depth) |
@@ -213,8 +213,8 @@ discard block |
||
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
216 | - * @param $request |
|
217 | - * @param $session |
|
216 | + * @param Request $request |
|
217 | + * @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session |
|
218 | 218 | */ |
219 | 219 | private function error($request, $session) |
220 | 220 | { |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | /** |
247 | 247 | * Error message for Ajax |
248 | - * @param $form |
|
248 | + * @param \Symfony\Component\Form\Form $form |
|
249 | 249 | * @return Response |
250 | 250 | */ |
251 | 251 | private function returnAjaxErrors($form) |
@@ -32,30 +32,30 @@ discard block |
||
32 | 32 | |
33 | 33 | $comment_class_name = $this->container->getParameter('mykees_comment.comment.class'); |
34 | 34 | $comment_class = new $comment_class_name(); |
35 | - $form = $this->createForm($this->get('mykees.comment.form'),$comment_class); |
|
35 | + $form = $this->createForm($this->get('mykees.comment.form'), $comment_class); |
|
36 | 36 | |
37 | - if('POST' == $request->getMethod()) { |
|
37 | + if ('POST' == $request->getMethod()) { |
|
38 | 38 | |
39 | 39 | if ($form->handleRequest($request)->isValid()) { |
40 | 40 | |
41 | - if($request->isXmlHttpRequest()) { |
|
42 | - return $this->ajaxInfo($params,$request,$comment_class); |
|
41 | + if ($request->isXmlHttpRequest()) { |
|
42 | + return $this->ajaxInfo($params, $request, $comment_class); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | $this->postInfo($params, $request, $comment_class, $params['session']); |
46 | 46 | |
47 | - }else{ |
|
47 | + }else { |
|
48 | 48 | |
49 | - if($request->isXmlHttpRequest()) { |
|
49 | + if ($request->isXmlHttpRequest()) { |
|
50 | 50 | return $this->returnAjaxErrors($form); |
51 | - }else{ |
|
51 | + }else { |
|
52 | 52 | $this->error($request, $params['session']); |
53 | 53 | } |
54 | 54 | } |
55 | 55 | |
56 | 56 | } |
57 | 57 | |
58 | - return $this->redirect($request->headers->get('referer') . '#comments_area'); |
|
58 | + return $this->redirect($request->headers->get('referer').'#comments_area'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | * @param $comment_class |
65 | 65 | * @return Response |
66 | 66 | */ |
67 | - private function ajaxInfo($params,$request,$comment_class) |
|
67 | + private function ajaxInfo($params, $request, $comment_class) |
|
68 | 68 | { |
69 | 69 | |
70 | 70 | $comment = $this->postInfo($params, $request, $comment_class, $params['session']); |
71 | 71 | $comment_depth = $this->container->getParameter('comment.depth'); |
72 | 72 | |
73 | 73 | // Si la profondeur du commentaire parent est inférieure ou égale à la profondeur définis |
74 | - if($request->request->get('depth') < $comment_depth && $comment_depth >= 1) |
|
74 | + if ($request->request->get('depth') < $comment_depth && $comment_depth >= 1) |
|
75 | 75 | { |
76 | - $comment->setDepthReached($request->request->get('depth') + 1);//On incremente la profondeur max |
|
76 | + $comment->setDepthReached($request->request->get('depth') + 1); //On incremente la profondeur max |
|
77 | 77 | $comment->setDepth($comment->getId()); //la profondeur de réponse est égale a l'id |
78 | 78 | $max_depth = false; |
79 | - }else{ |
|
80 | - $comment->setDepthReached($request->request->get('depth'));//On à atteint la profondeur max |
|
81 | - $comment->setDepth($comment->getParentId());//la profondeur de réponse est éagle au commentaire parent |
|
79 | + }else { |
|
80 | + $comment->setDepthReached($request->request->get('depth')); //On à atteint la profondeur max |
|
81 | + $comment->setDepth($comment->getParentId()); //la profondeur de réponse est éagle au commentaire parent |
|
82 | 82 | $max_depth = true; |
83 | 83 | } |
84 | 84 | |
85 | - $template = $this->renderResponse($comment,$request,$max_depth); |
|
85 | + $template = $this->renderResponse($comment, $request, $max_depth); |
|
86 | 86 | $json = json_encode([ |
87 | 87 | 'template'=>$template, |
88 | 88 | "parent_id"=>$comment->getParentId(), |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | * @param $max_depth |
102 | 102 | * @return string |
103 | 103 | */ |
104 | - private function renderResponse($comment,$request,$max_depth) |
|
104 | + private function renderResponse($comment, $request, $max_depth) |
|
105 | 105 | { |
106 | - if($comment->getParentId() > 0) |
|
106 | + if ($comment->getParentId() > 0) |
|
107 | 107 | { |
108 | - if( ($request->request->get('response_type') === "true" && $max_depth === true) || |
|
108 | + if (($request->request->get('response_type') === "true" && $max_depth === true) || |
|
109 | 109 | ($request->request->get('response_type') === "false" && $max_depth === true) || |
110 | 110 | ($request->request->get('response_type') === "true" && $max_depth === false) |
111 | - ){ |
|
112 | - return $this->renderView('MykeesCommentBundle:Comments:unwrap_replies.html.twig',['comment'=>$comment,'recent_reply'=>true]); |
|
113 | - }else{ |
|
114 | - return $this->renderView('MykeesCommentBundle:Comments:replies.html.twig',['comment'=>$comment,'recent_reply'=>true]); |
|
111 | + ) { |
|
112 | + return $this->renderView('MykeesCommentBundle:Comments:unwrap_replies.html.twig', ['comment'=>$comment, 'recent_reply'=>true]); |
|
113 | + }else { |
|
114 | + return $this->renderView('MykeesCommentBundle:Comments:replies.html.twig', ['comment'=>$comment, 'recent_reply'=>true]); |
|
115 | 115 | } |
116 | - }else{ |
|
117 | - return $this->renderView('MykeesCommentBundle:Comments:comment.html.twig',['comment'=>$comment,'recent_reply'=>true]); |
|
116 | + }else { |
|
117 | + return $this->renderView('MykeesCommentBundle:Comments:comment.html.twig', ['comment'=>$comment, 'recent_reply'=>true]); |
|
118 | 118 | } |
119 | 119 | } |
120 | 120 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | private function postInfo($params, $request, $comment, $session) |
131 | 131 | { |
132 | 132 | $this->userInfo($request, $comment); |
133 | - $this->commentInfo($params,$comment,$request,$params['ref_id']); |
|
133 | + $this->commentInfo($params, $comment, $request, $params['ref_id']); |
|
134 | 134 | |
135 | 135 | $this->save($comment); |
136 | 136 | $this->messageFlash($session); |
@@ -158,14 +158,14 @@ discard block |
||
158 | 158 | * @param $ref_id |
159 | 159 | * @return mixed |
160 | 160 | */ |
161 | - private function commentInfo($params,$comment,$request,$ref_id) |
|
161 | + private function commentInfo($params, $comment, $request, $ref_id) |
|
162 | 162 | { |
163 | 163 | $comment->setIp($request->getClientIp()); |
164 | 164 | $comment->setModel($params['ref']); |
165 | 165 | $comment->setModelId($ref_id); |
166 | 166 | //Spam ? |
167 | 167 | $akismet = $this->container->hasParameter('akismet') ? $this->container->getParameter('akismet') : null; |
168 | - $params['manager']->isSpam($comment,$request,$akismet) ? $comment->setSpam(1) : $comment->setSpam(0); |
|
168 | + $params['manager']->isSpam($comment, $request, $akismet) ? $comment->setSpam(1) : $comment->setSpam(0); |
|
169 | 169 | |
170 | 170 | return $comment; |
171 | 171 | } |
@@ -178,15 +178,15 @@ discard block |
||
178 | 178 | */ |
179 | 179 | private function userInfo($request, $comment) |
180 | 180 | { |
181 | - $is_join = method_exists($comment,'getUser') ? true : false; |
|
181 | + $is_join = method_exists($comment, 'getUser') ? true : false; |
|
182 | 182 | |
183 | - if($this->getUser() !== null) |
|
183 | + if ($this->getUser() !== null) |
|
184 | 184 | { |
185 | - if($this->getUser()->getUsername() != $comment->getUsername() || $this->getUser()->getEmail() != $comment->getEmail()) |
|
185 | + if ($this->getUser()->getUsername() != $comment->getUsername() || $this->getUser()->getEmail() != $comment->getEmail()) |
|
186 | 186 | { |
187 | - return $this->redirect($request->headers->get('referer') . '#comments_area'); |
|
187 | + return $this->redirect($request->headers->get('referer').'#comments_area'); |
|
188 | 188 | } |
189 | - if($is_join) |
|
189 | + if ($is_join) |
|
190 | 190 | { |
191 | 191 | $comment->setUser($this->getUser()); |
192 | 192 | } |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | private function messageFlash($session) |
204 | 204 | { |
205 | 205 | $html = $session->has('success_message') ? $session->get('success_message') : "<strong>Merci!</strong> Votre message à bien été posté."; |
206 | - if($this->get('session')->getFlashBag()->has('comment_success')) |
|
206 | + if ($this->get('session')->getFlashBag()->has('comment_success')) |
|
207 | 207 | { |
208 | - $this->get('session')->getFlashBag()->set('comment_success',''); |
|
208 | + $this->get('session')->getFlashBag()->set('comment_success', ''); |
|
209 | 209 | } |
210 | - $this->get('session')->getFlashBag()->add('comment_success',$html); |
|
210 | + $this->get('session')->getFlashBag()->add('comment_success', $html); |
|
211 | 211 | |
212 | 212 | return true; |
213 | 213 | } |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | private function error($request, $session) |
220 | 220 | { |
221 | 221 | $requestData = $request->request->get('mykees_comment'); |
222 | - if(!empty($requestData)) |
|
222 | + if (!empty($requestData)) |
|
223 | 223 | { |
224 | - $session->set('form_comment_data',$request->request->get('mykees_comment')); |
|
224 | + $session->set('form_comment_data', $request->request->get('mykees_comment')); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | */ |
251 | 251 | private function returnAjaxErrors($form) |
252 | 252 | { |
253 | - $json = json_encode(['error'=>'error','error_fields'=>$this->getErrorsAsArray($form)]); |
|
253 | + $json = json_encode(['error'=>'error', 'error_fields'=>$this->getErrorsAsArray($form)]); |
|
254 | 254 | return new Response($json); |
255 | 255 | } |
256 | 256 | } |
@@ -16,7 +16,7 @@ |
||
16 | 16 | /** |
17 | 17 | * Returns a list of functions to add to the existing list. |
18 | 18 | * |
19 | - * @return array An array of functions |
|
19 | + * @return \Twig_SimpleFunction[] An array of functions |
|
20 | 20 | */ |
21 | 21 | public function getFunctions() |
22 | 22 | { |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | use Symfony\Component\Validator\Constraints\DateTime; |
13 | 13 | |
14 | -class CommentExtension extends \Twig_Extension{ |
|
14 | +class CommentExtension extends \Twig_Extension { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Returns a list of functions to add to the existing list. |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - public function commentForm(\Twig_Environment $env, $form, $ajax=false, $options=[]) |
|
45 | + public function commentForm(\Twig_Environment $env, $form, $ajax = false, $options = []) |
|
46 | 46 | { |
47 | - return $env->render('MykeesCommentBundle:Comments:form.html.twig',[ |
|
47 | + return $env->render('MykeesCommentBundle:Comments:form.html.twig', [ |
|
48 | 48 | 'form'=>$form, |
49 | 49 | 'ajax'=>$ajax, |
50 | 50 | 'options'=>$options |
@@ -58,16 +58,16 @@ discard block |
||
58 | 58 | * @param bool $canAdminComment |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - public function commentsList(\Twig_Environment $env,$comments, $canAdminComment=false, $options=[]) |
|
61 | + public function commentsList(\Twig_Environment $env, $comments, $canAdminComment = false, $options = []) |
|
62 | 62 | { |
63 | - return $env->render('MykeesCommentBundle:Comments:comments.html.twig',[ |
|
63 | + return $env->render('MykeesCommentBundle:Comments:comments.html.twig', [ |
|
64 | 64 | 'comments'=>$comments, |
65 | 65 | "canAdminComment"=>$canAdminComment |
66 | 66 | ]); |
67 | 67 | } |
68 | 68 | |
69 | 69 | |
70 | - public function dateInterval($date,$locale) |
|
70 | + public function dateInterval($date, $locale) |
|
71 | 71 | { |
72 | 72 | $comment_date = new \DateTime($date); |
73 | 73 | $dateNow = new \DateTime('NOW'); |
@@ -81,25 +81,25 @@ discard block |
||
81 | 81 | $interval->format('%i') |
82 | 82 | ]; |
83 | 83 | $unity_en = [ |
84 | - ['year','years'], |
|
85 | - ['month','months'], |
|
86 | - ['day','days'], |
|
87 | - ['hour','hours'], |
|
88 | - ['minute','minutes'] |
|
84 | + ['year', 'years'], |
|
85 | + ['month', 'months'], |
|
86 | + ['day', 'days'], |
|
87 | + ['hour', 'hours'], |
|
88 | + ['minute', 'minutes'] |
|
89 | 89 | ]; |
90 | 90 | $unity_fr = [ |
91 | - ['an','ans'], |
|
92 | - ['mois','mois'], |
|
93 | - ['jour','jours'], |
|
94 | - ['heure','heures'], |
|
95 | - ['minute','minutes'] |
|
91 | + ['an', 'ans'], |
|
92 | + ['mois', 'mois'], |
|
93 | + ['jour', 'jours'], |
|
94 | + ['heure', 'heures'], |
|
95 | + ['minute', 'minutes'] |
|
96 | 96 | ]; |
97 | 97 | |
98 | 98 | $periodesLength = count($periodes); |
99 | 99 | |
100 | - for($i=0; $i < $periodesLength; $i++) |
|
100 | + for ($i = 0; $i < $periodesLength; $i++) |
|
101 | 101 | { |
102 | - if(intval($periodes[$i]) >= 1 && $i < count($periodes)) |
|
102 | + if (intval($periodes[$i]) >= 1 && $i < count($periodes)) |
|
103 | 103 | { |
104 | 104 | $locale_unity = $locale == "fr" ? $unity_fr : $unity_en; |
105 | 105 | $u = $periodes[$i] > 1 ? $locale_unity[$i][1] : $locale_unity[$i][0]; |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | return $periodes[$i].' '.$u; |
108 | 108 | } |
109 | 109 | } |
110 | - if($locale == 'fr') |
|
110 | + if ($locale == 'fr') |
|
111 | 111 | { |
112 | 112 | return "moins d'une minute"; |
113 | - }else{ |
|
113 | + }else { |
|
114 | 114 | return 'less than a minute'; |
115 | 115 | } |
116 | 116 | } |
@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | public function deleteWithChildrenAction($model, $model_id, $comment_id, Request $request) |
16 | 16 | { |
17 | 17 | $manager = $this->get('mykees.comment.query.manager'); |
18 | - $comments = $manager->findCommentsByModelAndId($model, $model_id,true); |
|
18 | + $comments = $manager->findCommentsByModelAndId($model, $model_id, true); |
|
19 | 19 | $children_ids = $manager->getChildren($comments[$comment_id]); |
20 | 20 | |
21 | - array_push($children_ids,$comment_id); |
|
21 | + array_push($children_ids, $comment_id); |
|
22 | 22 | |
23 | 23 | $manager->deleteByCommentIds($children_ids); |
24 | 24 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function deleteAction($id, Request $request) |
30 | 30 | { |
31 | 31 | $class = $this->container->getParameter('mykees_comment.comment.class'); |
32 | - $explose_class = explode('\\',$class); |
|
32 | + $explose_class = explode('\\', $class); |
|
33 | 33 | $repository = $explose_class[0].$explose_class[1].':'.$explose_class[3]; |
34 | 34 | $comment = $this->gEm()->getRepository($repository)->find($id); |
35 | 35 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
14 | 14 | use Symfony\Component\DependencyInjection\ContainerInterface; |
15 | 15 | |
16 | -class LoadCommentData implements FixtureInterface,ContainerAwareInterface{ |
|
16 | +class LoadCommentData implements FixtureInterface, ContainerAwareInterface{ |
|
17 | 17 | |
18 | 18 | public $container; |
19 | 19 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $comment_class = $this->container->getParameter('mykees_comment.comment.class'); |
40 | 40 | |
41 | - for($i=1; $i<=5 ;$i++) |
|
41 | + for ($i = 1; $i <= 5; $i++) |
|
42 | 42 | { |
43 | 43 | $comment = new $comment_class(); |
44 | 44 | $comment->setUsername('admin'.$i); |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | $comment->setContent('contenu n-'.$i); |
47 | 47 | $comment->setCreatedAt(new \DateTime()); |
48 | 48 | $comment->setModel('Post'); |
49 | - if($i <= 3) |
|
49 | + if ($i <= 3) |
|
50 | 50 | { |
51 | 51 | $comment->setModelId(1); |
52 | - }else{ |
|
52 | + }else { |
|
53 | 53 | $comment->setModelId($i); |
54 | 54 | } |
55 | 55 | $comment->setParentId(0); |
@@ -314,7 +314,7 @@ |
||
314 | 314 | */ |
315 | 315 | public function setChildren(Comment $children) |
316 | 316 | { |
317 | - array_unshift($this->children,$children); |
|
317 | + array_unshift($this->children, $children); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -24,20 +24,20 @@ |
||
24 | 24 | ->add('username') |
25 | 25 | ->add('email') |
26 | 26 | ->add('content') |
27 | - ->add('model',"text",[ |
|
27 | + ->add('model', "text", [ |
|
28 | 28 | 'required'=>false |
29 | 29 | ]) |
30 | - ->add('modelId',"text",[ |
|
30 | + ->add('modelId', "text", [ |
|
31 | 31 | 'required'=>false |
32 | 32 | ]) |
33 | - ->add('parentId',"text",[ |
|
33 | + ->add('parentId', "text", [ |
|
34 | 34 | 'required'=>false |
35 | 35 | ]) |
36 | - ->add('spam',"text",[ |
|
36 | + ->add('spam', "text", [ |
|
37 | 37 | 'required'=>false, |
38 | 38 | 'data'=>0 |
39 | 39 | ]) |
40 | - ->add('ip',"text",[ |
|
40 | + ->add('ip', "text", [ |
|
41 | 41 | 'required'=>false |
42 | 42 | ]) |
43 | 43 | ; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function __construct(TokenStorageInterface $tokenStorage) |
20 | 20 | { |
21 | 21 | $this->tokenStorage = $tokenStorage->getToken(); |
22 | - $this->user = method_exists($this->tokenStorage,'getUser') ? $this->tokenStorage->getUser() : array(); |
|
22 | + $this->user = method_exists($this->tokenStorage, 'getUser') ? $this->tokenStorage->getUser() : array(); |
|
23 | 23 | } |
24 | 24 | /** |
25 | 25 | * @param FormBuilderInterface $builder |
@@ -27,34 +27,34 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function buildForm(FormBuilderInterface $builder, array $options) |
29 | 29 | { |
30 | - if(empty($this->user) || $this->user == 'anon.') |
|
30 | + if (empty($this->user) || $this->user == 'anon.') |
|
31 | 31 | { |
32 | 32 | $builder |
33 | - ->add('username','text',[ |
|
33 | + ->add('username', 'text', [ |
|
34 | 34 | 'label'=> $this->username |
35 | 35 | ]) |
36 | - ->add('email','text',[ |
|
36 | + ->add('email', 'text', [ |
|
37 | 37 | 'label'=> $this->email |
38 | 38 | ]) |
39 | - ->add('content','textarea',[ |
|
39 | + ->add('content', 'textarea', [ |
|
40 | 40 | 'label'=> $this->content |
41 | 41 | ]) |
42 | - ->add('parentId','hidden',['data'=>0]) |
|
43 | - ->add('model','hidden') |
|
44 | - ->add('modelId','hidden') |
|
42 | + ->add('parentId', 'hidden', ['data'=>0]) |
|
43 | + ->add('model', 'hidden') |
|
44 | + ->add('modelId', 'hidden') |
|
45 | 45 | ; |
46 | - }else{ |
|
46 | + }else { |
|
47 | 47 | $builder |
48 | - ->add('username','hidden',[ |
|
48 | + ->add('username', 'hidden', [ |
|
49 | 49 | 'data'=>$this->user->getUsername() |
50 | 50 | ]) |
51 | - ->add('email','hidden',[ |
|
51 | + ->add('email', 'hidden', [ |
|
52 | 52 | 'data'=>$this->user->getEmail() |
53 | 53 | ]) |
54 | 54 | ->add('content') |
55 | - ->add('parentId','hidden',['data'=>0]) |
|
56 | - ->add('model','hidden') |
|
57 | - ->add('modelId','hidden') |
|
55 | + ->add('parentId', 'hidden', ['data'=>0]) |
|
56 | + ->add('model', 'hidden') |
|
57 | + ->add('modelId', 'hidden') |
|
58 | 58 | ; |
59 | 59 | } |
60 | 60 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | use Mykees\CommentBundle\Manager\CommentQueryManager; |
9 | 9 | use Doctrine\Common\Persistence\ManagerRegistry; |
10 | 10 | |
11 | -class CommentListener{ |
|
11 | +class CommentListener { |
|
12 | 12 | |
13 | 13 | |
14 | 14 | public $container; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | { |
24 | 24 | $this->managerRegistry = $managerRegistry; |
25 | 25 | $this->class = $class; |
26 | - $this->fos_user = $fos_user_class; |
|
26 | + $this->fos_user = $fos_user_class; |
|
27 | 27 | $this->depth = $depth; |
28 | 28 | } |
29 | 29 | |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | { |
33 | 33 | $model = $args->getEntity(); |
34 | 34 | |
35 | - if($model instanceof IsCommentable) |
|
35 | + if ($model instanceof IsCommentable) |
|
36 | 36 | { |
37 | - $manager = new CommentQueryManager($this->managerRegistry,$this->class,$this->depth); |
|
37 | + $manager = new CommentQueryManager($this->managerRegistry, $this->class, $this->depth); |
|
38 | 38 | $manager->preDeleteComment($model); |
39 | 39 | } |
40 | 40 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | use Symfony\Component\HttpFoundation\Session\Session; |
17 | 17 | use Mykees\CommentBundle\Form\Type\CommentFormType; |
18 | 18 | |
19 | -class CommentManager extends Manager{ |
|
19 | +class CommentManager extends Manager { |
|
20 | 20 | |
21 | 21 | protected $formFactory; |
22 | 22 | protected $router; |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | * @param null $success_message |
43 | 43 | * @return \Symfony\Component\Form\Form |
44 | 44 | */ |
45 | - public function createForm(IsCommentable $model, $labels = [], $success_message=null) |
|
45 | + public function createForm(IsCommentable $model, $labels = [], $success_message = null) |
|
46 | 46 | { |
47 | 47 | $dataForm = $this->session->get('form_comment_data'); |
48 | - $model_name = $this->getClassShortName($model); |
|
48 | + $model_name = $this->getClassShortName($model); |
|
49 | 49 | $route = $this->router->generate('mykees_comment_manage'); |
50 | 50 | $comment = new $this->comment_class; |
51 | 51 | $comment->setModel($model_name); |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | $this->formType->content = !empty($labels['content']) ? $labels['content'] : false; |
57 | 57 | |
58 | 58 | |
59 | - if($this->session->has('success_message')) { $this->session->remove('success_message'); } |
|
60 | - if($success_message) { $this->session->set('success_message',$success_message); } |
|
59 | + if ($this->session->has('success_message')) { $this->session->remove('success_message'); } |
|
60 | + if ($success_message) { $this->session->set('success_message', $success_message); } |
|
61 | 61 | |
62 | 62 | $form = $this->formFactory->create( |
63 | 63 | $this->formType, |
64 | 64 | $comment, |
65 | - ['action'=> $route,'method'=> 'POST'] |
|
65 | + ['action'=> $route, 'method'=> 'POST'] |
|
66 | 66 | ); |
67 | 67 | |
68 | - if( !empty($dataForm) ){ |
|
68 | + if (!empty($dataForm)) { |
|
69 | 69 | $form->submit($dataForm); |
70 | 70 | $this->session->remove('form_comment_data'); |
71 | 71 | } |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function isSpam($comment, Request $request, $akismetInit) |
85 | 85 | { |
86 | - if($akismetInit){ |
|
87 | - $akismet = new Akismet($akismetInit['website'],$akismetInit['api_key'],$request); |
|
86 | + if ($akismetInit) { |
|
87 | + $akismet = new Akismet($akismetInit['website'], $akismetInit['api_key'], $request); |
|
88 | 88 | |
89 | 89 | $akismet->setCommentAuthor($comment->getUsername()); |
90 | 90 | $akismet->setCommentAuthorEmail($comment->getEmail()); |