This bundle gives a service that permits to normalize a doctrine entity.
The entity is normalized and the ids of the foreign entities of the entity are also normalized.
composer require "tbn/getsetforeignnormalizer-bundle"
$normalizer = $this->get('get_set_foreign_normalizer');
$normalizer->normalize($entities, true, false, array('allImages'));//avoid the getAllImages function
You can normalize all entities using
$normalizer->normalize($entities, true);