Created
December 6, 2017 21:34
-
-
Save NandoKstroNet/c22f65be250a9f505c3d70abbde8a05a to your computer and use it in GitHub Desktop.
Utilizando templates twig em nosso controller Symfony 4, post sobre templates no Symfony 4 - Blog Code Experts Learning blog.codeexpertslearning.com.br
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Controller; | |
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | |
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; | |
use Symfony\Component\HttpFoundation\Response; | |
use App\Entity\Product; | |
class ProductController extends AbstractController | |
{ | |
/** | |
* @Route("/", name="product_home") | |
*/ | |
public function index() | |
{ | |
$products = $this->getDoctrine() | |
->getRepository(Product::class) | |
->findAll(); | |
return $this->render('products/index.html.twig',[ | |
'products' => $products | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment