Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Fhh\Bundle\ProductBundle\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
- use Symfony\Component\HttpFoundation\Response;
- use Fhh\Bundle\ProductBundle\Entity\Product;
- /**
- * @Route("/product")
- */
- class DefaultController extends Controller
- {
- /**
- * @Route("/list")
- */
- public function list(){
- $product = new Product();
- $list=$this->getDoctrine()->getRepository('FhhProductBundle:Product')->findAll();
- foreach ($list as $row) {
- $data['content']=array(
- 'id_product'=>$row->getId_product(),
- 'product_name'=>$row->getProduct_name(),
- );
- }
- var_dump($data);
- return $this->render('@FhhProductBundle/Resources/views/Default/list-product.html.twig',$data);
- }
- }
- ==============================
- twig nya
- ==============================
- {{dump(content) }}
- <br>
- <table>
- <tr>
- <th>Id</th>
- <th>Nama Barang</th>
- </tr>
- {% for isi in content %}
- <tr>
- <td>{{isi.id_product}}</td>
- <td>{{isi.product_name}}</td>
- </tr>
- {% endfor %}
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement