Napisałem sobie "system" komentarzy i wszystko jest ok, wszystko działa tylko każdy komentarz powoduje kolejne zapytanie do bazy (kolejny sybkomentarz tego nie powoduje) danych mimo iż komentarz odbieram raz w kontrolerze
dane mam relacyjnie tj tak:
post->komentarze->subKomentarze->autor
->autor
czyli post ma X komentarzy każdy komentarz ma autora i X subkomentarzy i każdy subkomentarz ma autora :)
//odbieram dane
$contener = $this->getDoctrine()
->getRepository('MakosoBlogBundle:MenuCollection')->find( $id );
//przekazuję do widoku
return [
'commentaryForm'=>$form->createView(),
'contener' => $contener,
'menu' => $this->getMenu()
];
proces renderowania jest dosyć długi ale mimo to wstawiam:
http://pastebin.com/MerNqTyh
Pytanie brzmi czy da się jakoś sprawnie załatwić sprawę aby od-razu pobierało wszystkie komentarze?
dodam jeszcze drugie pytanie chyab gdzieś popełniłem błąd przy pamowaniu gdy dodałem sub komentarze dostaję takie errory:
Entities Mapping
Class |
Mapping errors |
Makoso\BlogBundle\Entity\User |
- The association Makoso\BlogBundle\Entity\User#comments refers to the owning side field Makoso\BlogBundle\Entity\MenuCollection#author which does not exist.
- The mappings Makoso\BlogBundle\Entity\User#subcomments and Makoso\BlogBundle\Entity\Comment#author are inconsistent with each other.
|
Makoso\BlogBundle\Entity\MenuCollection |
No errors. |
Makoso\BlogBundle\Entity\MenuCategory |
No errors. |
Makoso\BlogBundle\Entity\Comment |
- The mappings Makoso\BlogBundle\Entity\Comment#subcomments and Makoso\BlogBundle\Entity\SubComment#comment are inconsistent with each other.
|
Makoso\BlogBundle\Entity\SubComment |
- The association Makoso\BlogBundle\Entity\SubComment#comment refers to the inverse side field Makoso\BlogBundle\Entity\Comment#comments which does not exist.
|
EDIT: Naprawiłem błędy mapowania