Skip to content
Advertisement

How can I get access to related entities with Symfony doctrine?

I try to find all documents that are related to my product:

JavaScript

But I get the error message:

Attempted to call an undefined method named “getId” of class “DoctrineORMPersistentCollection”.

Advertisement

Answer

The $value->getDocuments() return an array of Doctrine objects, or a PersistentCollection.

Your object may have a getId() function, but the PersistentCollection doesn’t.

You can loop over the Collection :

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement