So I have a poll class with a createdBy value (userID of the person who submitted it), then a controller that lists all polls in the poll table
public function indexAction()
{
$entityManager = $this->getDoctrine()->getManager();
$posts = $entityManager->getRepository(Poll::class)->findBy([], ['createdDate' => 'DESC']);
return $this->render('poll/admin/index.html.twig', ['posts' => $posts]);
}
My twig template looks a little like this at the momemt
<tbody>
{% for poll in posts %}
<tr id="poll_{{ poll.id }}">
<td> {{ poll.title }}</td>
<td>{{ poll.createdBy }}</td>
<td>etc</td>
<td>etc</td>
<td>etc</td>
</tr>
{% endfor %}
</tbody>
If I want to display the actual username instead of the createdBy ID, what would the best practice be? I'm using FOSUserBundle