[Flow] problem with an unidirectional one-to-many relations
Alexander Berl
a.berl at outlook.com
Thu Jun 20 18:13:00 CEST 2013
The code looks good so far. Some points you might want to check for:
- in case you are on latest 2.0, you should check that the
newPartieAdverseAction is called by a POST or PUT request, rather than a
GET request. The reason is that GET/HEAD ("safe") Requests no longer
trigger a doctrine persist. Read
http://robertlemke.com/en/blog/no-more-csrf-hassles-safe-requests-in-typo3-flow-2-0.html
also for more background information
- try adding a cascade attribute to your ManyToMany annotation
Regards,
Alexander
Am 19.06.2013 13:13, schrieb Kompaoré Désiré:
> Hi,
>
> I have a problem with an unidirectional one-to-many relations in my flow
> application.
> I've a domain model (Dossier) which contains a manytomany property as
> described bellow :
>
> /*
> * @Flow\Entity
> */
> class Dossier {
> /**
> * @var
> \Doctrine\Common\Collections\Collection<\Kode\Crm\Domain\Model\Client>
> * @ORM\ManyToMany
> *
> @ORM\JoinTable(inverseJoinColumns={@ORM\JoinColumn(unique=true)})
> */
> protected $partiesAdverses;
>
> public function __construct() {
> $this->partiesAdverses = new
> \Doctrine\Common\Collections\ArrayCollection();
> }
>
> /**
> *
> * @param \Kode\Crm\Domain\Model\Client $partieAdverse
> * @return void
> */
> public function addPartieAdverse(\Kode\Crm\Domain\Model\Client
> $partieAdverse) {
> $this->partiesAdverses->add($partieAdverse);
> }
>
> /**
> * Getter for parties adverses
> *
> * @return
> \Doctrine\Common\Collections\Collection<\Kode\Crm\Domain\Model\Client>
> */
> public function getPartiesAdverses() {
> return $this->partiesAdverses;
> }
>
> /**
> *
> * @param \Kode\Crm\Domain\Model\Client $partieAdverse
> * @return void
> */
> public function removePartieAdverse(\Kode\Crm\Domain\Model\Client
> $partieAdverse) {
> $this->partiesAdverses->removeElement($partieAdverse);
> }
> }
>
> A dossier can have many "partiesAdverses" (which are client) but i don't
> want to record the inversed side.
>
> Here is my controller action:
>
> /**
>
> * @param \Kode\Crm\Domain\Model\Dossier $dossier
> * @param \Kode\Crm\Domain\Model\Client $client
> * @return void
> */
> public function
> newPartieAdverseAction(\Kode\Crm\Domain\Model\Dossier $dossier,
> \Kode\Crm\Domain\Model\Client $client) {
> $dossier->addPartieAdverse($client);
> $this->dossierRepository->update($dossier);
> $this->redirect('index');
> }
>
> My problem is that when i create a newPartieAdverse, nothing is
> persisted in the created join table
> kode_crm_domain_model_dossier_partiesadverses_join
>
> Is it the right way to do the stuff?
> Thank's in advance
>
> Regards
>
> Désiré Kompaoré
>
>
>
>
More information about the Flow
mailing list