Advertisement
fahmihilmansyah

phptwigerror

Sep 28th, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Fhh\Bundle\ProductBundle\Controller;
  4.  
  5. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Fhh\Bundle\ProductBundle\Entity\Product;
  10.  
  11. /**
  12.  * @Route("/product")
  13.  */
  14. class DefaultController extends Controller
  15. {
  16.     /**
  17.      * @Route("/list")
  18.      */
  19.     public function list(){
  20.         $product = new Product();
  21.         $list=$this->getDoctrine()->getRepository('FhhProductBundle:Product')->findAll();
  22.        
  23.         foreach ($list as $row) {
  24.             $data['content']=array(
  25.                 'id_product'=>$row->getId_product(),
  26.                 'product_name'=>$row->getProduct_name(),
  27.                 );
  28.         }
  29.         var_dump($data);
  30.         return $this->render('@FhhProductBundle/Resources/views/Default/list-product.html.twig',$data);
  31.     }
  32. }
  33. ==============================
  34. twig nya
  35. ==============================
  36.  
  37.  
  38. {{dump(content) }}
  39. <br>
  40. <table>
  41. <tr>
  42.     <th>Id</th>
  43.     <th>Nama Barang</th>
  44. </tr>
  45. {% for isi in content %}
  46.     <tr>
  47.         <td>{{isi.id_product}}</td>
  48.         <td>{{isi.product_name}}</td>
  49.     </tr>
  50.    
  51. {% endfor %}
  52. </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement