I would like to list all of my entity in a twig page.
I want to make a array of my entity and send the array in my twig page.
This is my entity list:
ps: sorry for my English
I would like to list all of my entity in a twig page.
I want to make a array of my entity and send the array in my twig page.
This is my entity list:
ps: sorry for my English
Usually you should post a real question or problem on StackOverflow, not only what you want...
According to the comment from @MKhalidJunaid and this link
Get array/list of entities from Doctrine
This is your solution.
AppController.php
public function entitiesAction() {
$entities= [];
$metas = $entityManager->getMetadataFactory()->getAllMetadata();
foreach ($metas as $meta) {
$entities[] = $meta->getName();
}
return render('entities.html.twig', [
'entities' => $entities
]);
}
entities.html.twig
<ul>
{% for entity in entities %}
<li>{{ entity }}</li>
{% endfor %}
</ul>