forked from SymfonyCasts/symfony-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-turbo-tweak-review-flash-system.diff
30 lines (28 loc) · 1.31 KB
/
pre-turbo-tweak-review-flash-system.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
diff --git a/src/Controller/ProductController.php b/src/Controller/ProductController.php
index 246fb96..e749f11 100644
--- a/src/Controller/ProductController.php
+++ b/src/Controller/ProductController.php
@@ -72,9 +72,13 @@ class ProductController extends AbstractController
public function productReviews(Product $product, CategoryRepository $categoryRepository, Request $request, EntityManagerInterface $entityManager)
{
$reviewForm = null;
+
+ if ($this->getUser()) {
+ $reviewForm = $this->createForm(ReviewForm::class, new Review($this->getUser(), $product));
+ }
+
if ($request->isMethod('POST')) {
$this->denyAccessUnlessGranted('ROLE_USER');
- $reviewForm = $this->createForm(ReviewForm::class, new Review($this->getUser(), $product));
$reviewForm->handleRequest($request);
diff --git a/templates/product/_reviews.html.twig b/templates/product/_reviews.html.twig
index fd40828..2a3093f 100644
--- a/templates/product/_reviews.html.twig
+++ b/templates/product/_reviews.html.twig
@@ -23,6 +23,4 @@
{{ form_end(reviewForm) }}
{% elseif not is_granted('ROLE_USER') %}
<p><a href="{{ path('app_login') }}">Log in</a> to post your review</p>
-{% else %}
- <div class="alert alert-success">Thanks for your review!</div>
{% endif %}