Entity choicelist without bringing the whole entity


Symfony forms have a nice entity type, but it will eat your memory if you have too large entity. Only answer I found while trying to find a fix for that was this nice StackOverflow answer, but nothing else.

The deal is to not bring the whole entity but only the needed information, like id and name to feed an HTML select tag. More details in the Gist: