Reputation: 39
I've wrote in a twig view this:
{% for catalog in box.getCatalogs() %}
{% for mod in catalog.getModel() %}
{{ dump(catalog.getModel()) }}
{% endfor %}
{% else %}
nothing
{% endfor %}
So how do get an array of collection in a twig view,?
Upvotes: 0
Views: 584
Reputation: 2972
You don't need to worry about the type of Collection object, Both ArrayCollection
and PersistentCollection
implement the Collection
interface and work the same way. The difference is that PersistentCollection contains objects that have been persisted in the DB and might hit the database when you iterate over them.
If you use type-hinting, just hint at Doctrine\Common\Collections\Collection
.
If you write
{% for mod in catalog.getModel() %}
{{ dump(mod) }}
{% endfor %}
in your twig template, you should see your objects.
Upvotes: 1