[FLOW3-general] Question about associations and JsonView
Davide CD
dmichelangeli at hotmail.com
Wed Apr 25 10:40:36 CEST 2012
Hi Christian,
I've found the solution, I pasted it in here:
http://pastebin.com/3vNvUQhc
Thanks for your support!
Davide
> From: christian.mueller at typo3.org
> Date: Wed, 25 Apr 2012 08:34:24 +0200
> To: flow3-general at lists.typo3.org
> Subject: Re: [FLOW3-general] Question about associations and JsonView
>
> Hey Davide,
>
> could you put the code on gist or pastebin, that would make matters much
> easier...
>
> Cheers,
> Christian
>
> [1] http://gist.github.com
> [2] http://pastebin.com
>
> On 24/04/12 11:27, Davide CD wrote:
> >
> > Sorry if I bother you again, but I really can't get this to work...
> > class Hotel{/*** Users is an array collection of User objects* @var \Doctrine\Common\Collections\Collection<\DKM\Services\Domain\Model\User>* @ORM\ManyToMany(inversedBy="hotels" , cascade={"persist"})* @ORM\JoinTable(name="dkm_services_domain_model_hotel_user_join") */ protected $users;
> > /*** Get the Hotel's users** @return \Doctrine\Common\Collections\Collection The Hotel's users*/public function getUsers() { return $this->users;}/** * Sets this Hotel's users * * @param \Doctrine\Common\Collections\Collection $users The Hotel's users * @return void */public function setUsers(\Doctrine\Common\Collections\Collection $users) { $this->users = $users;}
> > }
> > class User{
> > /** * @var \Doctrine\Common\Collections\Collection<\DKM\Services\Domain\Model\Hotel> * @ORM\ManyToMany(mappedBy="users" , cascade={"persist"}) */ protected $hotels; /** * Get the Users's hotels * * @return \Doctrine\Common\Collections\Collection The Users's hotels */ public function getHotels() { return $this->hotels; }
> > /** * Sets this User's hotel * * @param \Doctrine\Common\Collections\Collection $users The User's hotels * @return void */ public function setHotels(\Doctrine\Common\Collections\Collection $hotels) { $this->hotels = $hotels; }
> > }
> > I have an association table (jointable) with users and hotels (this is automatically generated by a doctrine:update command) and with two columns:
> > user|hotela bc b
> > So, two different users should belong to the same hotel. But if I dump the hotel object with the users associated, the users seem to be assigned to two different hotels.
> > And If I render the hotels thru a JsonView, I cannot display any user (actually, there's no "users" field in it) in the Json string.
> > Thank you in advance for any hint!Davide
>
>
>
>
> --
> Christian Mueller
> TYPO3 Core Team
>
> TYPO3 .... inspiring people to share!
> Get involved: typo3.org
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
More information about the FLOW3-general
mailing list