I have an array of objects
$objects = fetch objects from DB using Doctrine
In twig I want to make a foreach loop that displays the entity class names of the objects. I want this because the array exists out of different objects.
So i try this, ofcourse this does not work.
{% for object in objects %}
{{ object.entityClassName }}
{% endfor %}
How can i display the entity class name of the objects in twig?
I looked up this question : how can we get class name of the entity object in twig view
Is there a more simple solution to this problem? Wih
Simplest way is like one in that link You pasted:
public function getClassName()
{
return (new \ReflectionClass($this))->getShortName();
}
Add method above into your entity and than use it in twig:
{{ object.className }}