We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b9a1847 + 711b4b0 commit cb9ad70Copy full SHA for cb9ad70
doctrine.rst
@@ -518,6 +518,24 @@ be able to go to ``/product/1`` to see your new product::
518
// in the template, print things with {{ product.name }}
519
// return $this->render('product/show.html.twig', ['product' => $product]);
520
}
521
+
522
+Another possibility is to use the ``ProductRepository`` using Symfony's autowiring
523
+and injected by the dependency injection container::
524
525
+ // src/Controller/ProductController.php
526
+ // ...
527
+ use App\Repository\ProductRepository;
528
529
+ /**
530
+ * @Route("/product/{id}", name="product_show")
531
+ */
532
+ public function show($id, ProductRepository $productRepository)
533
+ {
534
+ $product = $productRepository
535
+ ->find($id);
536
537
538
+ }
539
540
Try it out!
541
0 commit comments