Professional Documents
Culture Documents
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
return $this->render('test/3A13.html.twig',[
'c'=>$klass,
'name'=>$n
]);
}
#[Route('/list', name: 'list')]
public function list(): Response
{
$authors = array(
array('id' => 1, 'picture' => '/images/Victor-Hugo.jpg','username' =>
'Victor Hugo', 'email' =>
'victor.hugo@gmail.com ', 'nb_books' => 100),
array('id' => 2, 'picture' => '/images/william-
shakespeare.jpg','username' => ' William Shakespeare', 'email' =>
' william.shakespeare@gmail.com', 'nb_books' => 200 ),
array('id' => 3, 'picture' => '/images/Taha_Hussein.jpg','username' =>
'Taha Hussein', 'email' =>
'taha.hussein@gmail.com', 'nb_books' => 300),
);
return $this->render('test/list.html.twig',[
'a'=>$authors
]);
}
TESTCONTROLLER STUDENT
<table border="2">
<tr>
<td>id</td>
<td>name</td>
<td>email</td>
<td>age</td>
<td>grade</td>
<td>Action</td>
</tr>
{% for a in response %}
<tr>
<td>{{a.id}}</td>
<td>{{a.name}}</td>
<td>{{a.email}}</td>
<td>{{a.age}}</td>
<td>{%if a.calssroom!=null%}
{{a.calssroom.name}}
{%endif%}</td>
<td><a href={{path('remove',{'id':a.id})}}>remove</a>
<a href={{path('update',{'id':a.id})}}>update</a>
</td>
</tr>
{% endfor %}
</table>