So, we have two entities. One with repository and another is not. When we trying to get the data from another table we will get the ArrayCollection data. Question is how to call this entity repository methods? Is it real?
Example:
$system = $this
->getDoctrine()
->getEntityManager()
->getRepository('SomeBundle:FirstEntity')
->findOneByColumnID($id);
$den = $system->getDataFromSecondTable(); // ArrayCollection of SecondEntity
And then i want to use some kind of:
$den[0]->functionFromSecondEntityRepository();
So, method “functionFromSecondEntityRepository” is in Repository of class SecondEntity and i can’t call it – error on undefined method call “functionFromSecondEntityRepository”.
So how can i do it in right way?
You didnt provide too many details so I will make some example up here.
Let’s say you have an Entity
FriendsListand aOne-to-Manyrelationship with EntityFriend.By default when you create relationships a method to acquire the collection is created, in this example
getFriendswhich returns an array of Entities. After you generate the entities look at your Entity Model to see which methods are available. By default one is created for each property in your entity and additional ones for Collections.The following is what a one-to-many relationship would look like if you use YAML configuration.
Accessing a Repository
YAML Configuration (services.yml)
On the Controller