1

I have a problem and of course i dont understand :) (and of course im french :)

On a table "evenement" i have a user linked. And When i do :

$repository = $this->getDoctrine()->getManager()->getRepository('AppBundle:Evenement');
$evt = $repository->findOneById($evt);
dump($evt)

All is ok, i can read my evt, but when in profiler i click on a child object "user", all property are null (except id, usermail, mail, password)

and its the same thing when i do :

dump($evt->getUser());

Why all property are not filled ?

thank you and sorry for my english.

1 Answer 1

1

It's most probably Lazy Loading. Properties are not beeing read from DB unless you need them.

Try to do the following:

$repository = $this->getDoctrine()->getManager()->getRepository('AppBundle:Evenement');
$evt = $repository->findOneById($evt);
$evt->getUser()->getRoles(); // Ot whatever properties your user has.
dump($evt)

In this case, dump will show this property populated.

Sign up to request clarification or add additional context in comments.

4 Comments

yeah that's worked if i do dump($evenement->getUser()->getCodePostal()); : ! but how i can populated all property in only one time?
Why would you need it? Just to inspect it through dump?
just put object in session for use in twig, by example {{ app.session.get('evt').user.email }}
Then just don't worry. When you will use data, it will be there. Until that moment - it will not. It's the essence of lazy loading - to save resources and to load only those data which is used in application

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.