Make some relations bidirectionnal

This commit is contained in:
Mathieu Jaumotte 2021-04-01 11:06:36 +02:00
parent 01f24ecf1f
commit 25634ba12b
3 changed files with 66 additions and 18 deletions

View File

@ -24,7 +24,9 @@ namespace Chill\PersonBundle\Entity;
use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin; use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@ -74,7 +76,16 @@ class AccompanyingPeriod
* @ORM\Column(type="text") * @ORM\Column(type="text")
*/ */
private $remark = ''; private $remark = '';
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Comment",
* mappedBy="accompanyingPeriod"
* )
*/
private $comments;
/** /**
* @var Collection * @var Collection
* *
@ -167,6 +178,15 @@ class AccompanyingPeriod
*/ */
private $confidential = false; private $confidential = false;
/**
* @var Collection
*
* @ORM\OneToMany(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\Resource",
* mappedBy="accompanyingPeriod"
* )
*/
private $resources;
/** /**
* AccompanyingPeriod constructor. * AccompanyingPeriod constructor.
@ -254,14 +274,8 @@ class AccompanyingPeriod
return false; return false;
} }
/** public function setRemark(string $remark): self
* Set remark
*
* @param string $remark
* @return AccompanyingPeriod
*/
public function setRemark($remark)
{ {
if ($remark === null) { if ($remark === null) {
$remark = ''; $remark = '';
@ -271,17 +285,29 @@ class AccompanyingPeriod
return $this; return $this;
} }
/** public function getRemark(): string
* Get remark
*
* @return string
*/
public function getRemark()
{ {
return $this->remark; return $this->remark;
} }
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
$this->comments[] = $comment;
return $this;
}
public function removeComment(Comment $comment): void
{
$this->comments->removeElement($comment);
}
/** /**
* Get Participations Collection * Get Participations Collection
*/ */
@ -557,4 +583,21 @@ class AccompanyingPeriod
{ {
$this->scopes->removeElement($scope); $this->scopes->removeElement($scope);
} }
public function getResources(): Collection
{
return $this->resources;
}
public function addResource(Resource $resource): self
{
$this->resources[] = $resource;
return $this;
}
public function removeResource(Resource $resource): void
{
$this->resources->removeElement($resource);
}
} }

View File

@ -41,7 +41,9 @@ class Comment
private $id; private $id;
/** /**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class) * @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
* inversedBy="comments")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*/ */
private $accompanyingPeriod; private $accompanyingPeriod;

View File

@ -43,7 +43,10 @@ class Resource
private $id; private $id;
/** /**
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class) * @ORM\ManyToOne(
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
* inversedBy="resources"
* )
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*/ */
private $accompanyingPeriod; private $accompanyingPeriod;