mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
Fixed: usage of owner side / inversed side on SocialAction / Evaluation
In a ManyToMany relationship, doctrine does take care only of the owning side of a relationship to inspect changes. ([see documentation](https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/unitofwork-associations.html#important-concepts)) This commit mark as "internal" the methods add/removeSocialAction on the inversed side (`Evaluation`) and let the methods add/removeEvaluation on the owning side (`SocialAction`) update the inversed side. The usage is also adapted into SocialWorkMetadata's importer.
This commit is contained in:
parent
c8c0c26ab9
commit
f1fc6f9ab3
@ -72,6 +72,9 @@ class Evaluation
|
|||||||
$this->socialActions = new ArrayCollection();
|
$this->socialActions = new ArrayCollection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @internal do use @see{SocialAction::addEvaluation}
|
||||||
|
*/
|
||||||
public function addSocialAction(SocialAction $socialAction): self
|
public function addSocialAction(SocialAction $socialAction): self
|
||||||
{
|
{
|
||||||
if (!$this->socialActions->contains($socialAction)) {
|
if (!$this->socialActions->contains($socialAction)) {
|
||||||
@ -111,6 +114,11 @@ class Evaluation
|
|||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return $this
|
||||||
|
*
|
||||||
|
* @internal do use @see{SocialAction::removeEvaluation}
|
||||||
|
*/
|
||||||
public function removeSocialAction(SocialAction $socialAction): self
|
public function removeSocialAction(SocialAction $socialAction): self
|
||||||
{
|
{
|
||||||
if ($this->socialActions->contains($socialAction)) {
|
if ($this->socialActions->contains($socialAction)) {
|
||||||
|
@ -112,6 +112,7 @@ class SocialAction
|
|||||||
{
|
{
|
||||||
if (!$this->evaluations->contains($evaluation)) {
|
if (!$this->evaluations->contains($evaluation)) {
|
||||||
$this->evaluations[] = $evaluation;
|
$this->evaluations[] = $evaluation;
|
||||||
|
$evaluation->addSocialAction($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@ -310,6 +311,7 @@ class SocialAction
|
|||||||
public function removeEvaluation(Evaluation $evaluation): self
|
public function removeEvaluation(Evaluation $evaluation): self
|
||||||
{
|
{
|
||||||
$this->evaluations->removeElement($evaluation);
|
$this->evaluations->removeElement($evaluation);
|
||||||
|
$evaluation->removeSocialAction($this);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ final class SocialWorkMetadata implements SocialWorkMetadataInterface
|
|||||||
/** @var Evaluation $eval */
|
/** @var Evaluation $eval */
|
||||||
$eval = $this->getOrCreateEntity($this->evaluationRepository, 'title', ['fr' => $evaluationTitle]);
|
$eval = $this->getOrCreateEntity($this->evaluationRepository, 'title', ['fr' => $evaluationTitle]);
|
||||||
$eval->setTitle(['fr' => $evaluationTitle]);
|
$eval->setTitle(['fr' => $evaluationTitle]);
|
||||||
$eval->addSocialAction($socialAction);
|
$socialAction->addEvaluation($eval);
|
||||||
|
|
||||||
$this->entityManager->persist($eval);
|
$this->entityManager->persist($eval);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user