The following entities exist, Farm, Barn and Animals. A Farm can have many Barns and a Barn many Animals.
When displaying a Farm in a TWIG template the number of Animals
Use Entity accessors :
{% for farm in farms %} {{ farm.name }} {% set barns = farm.getBarns() %} Barns count = {{ barns|length }} {% for barn in barns %} {% set animals = barn.getAnimals() %} {{ barn.name }} animals count : {{ animals|length }} {% endfor %} {% endfor %}