mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
make new relation many-to-many between Person and AccompagnyingPeriod
This commit is contained in:
@@ -206,10 +206,13 @@ class Person implements HasCenterInterface
|
||||
* The person's accompanying periods (when the person was accompanied by the center)
|
||||
* @var ArrayCollection
|
||||
*
|
||||
* @ORM\OneToMany(
|
||||
* @ORM\ManyToMany(
|
||||
* targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod",
|
||||
* mappedBy="person",
|
||||
* inversedBy="persons",
|
||||
* cascade={"persist", "remove", "merge", "detach"})
|
||||
* @ORM\JoinTable(
|
||||
* name="persons_accompanying_periods"
|
||||
* )
|
||||
*/
|
||||
private $accompanyingPeriods; //TO-CHANGE in accompanyingHistory
|
||||
|
||||
@@ -277,19 +280,20 @@ class Person implements HasCenterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriod $accompanyingPeriod
|
||||
* @uses AccompanyingPeriod::setPerson
|
||||
* Add AccompanyingPeriod
|
||||
*
|
||||
* @uses AccompanyingPeriod::addPerson
|
||||
*/
|
||||
public function addAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod)
|
||||
public function addAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) : void
|
||||
{
|
||||
$accompanyingPeriod->setPerson($this);
|
||||
$accompanyingPeriod->addPerson($this);
|
||||
$this->accompanyingPeriods->add($accompanyingPeriod);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AccompanyingPeriod $accompanyingPeriod
|
||||
* Remove AccompanyingPeriod
|
||||
*/
|
||||
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod)
|
||||
public function removeAccompanyingPeriod(AccompanyingPeriod $accompanyingPeriod) : void
|
||||
{
|
||||
$this->accompanyingPeriods->remove($accompanyingPeriod);
|
||||
}
|
||||
@@ -303,10 +307,8 @@ class Person implements HasCenterInterface
|
||||
* For closing a file, @see this::close
|
||||
*
|
||||
* To check if the Person and its accompanying period is consistent, use validation.
|
||||
*
|
||||
* @param AccompanyingPeriod $accompanyingPeriod
|
||||
*/
|
||||
public function open(AccompanyingPeriod $accompanyingPeriod)
|
||||
public function open(AccompanyingPeriod $accompanyingPeriod) : void
|
||||
{
|
||||
$this->proxyAccompanyingPeriodOpenState = true;
|
||||
$this->addAccompanyingPeriod($accompanyingPeriod);
|
||||
@@ -320,20 +322,17 @@ class Person implements HasCenterInterface
|
||||
*
|
||||
* To check if the Person and its accompanying period are consistent, use validation.
|
||||
*
|
||||
* @param accompanyingPeriod
|
||||
* @throws \Exception if two lines of the accompanying period are open.
|
||||
*/
|
||||
public function close(AccompanyingPeriod $accompanyingPeriod = null)
|
||||
public function close(AccompanyingPeriod $accompanyingPeriod = null) : void
|
||||
{
|
||||
$this->proxyAccompanyingPeriodOpenState = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the opened accompanying period.
|
||||
*
|
||||
* @return AccompanyingPeriod
|
||||
*/
|
||||
public function getOpenedAccompanyingPeriod()
|
||||
public function getOpenedAccompanyingPeriod() : AccompanyingPeriod
|
||||
{
|
||||
if ($this->isOpen() === false) {
|
||||
return null;
|
||||
@@ -349,29 +348,25 @@ class Person implements HasCenterInterface
|
||||
/**
|
||||
* Returns the opened accompanying period.
|
||||
*
|
||||
* @return AccompanyingPeriod
|
||||
* @deprecated since 1.1 use `getOpenedAccompanyingPeriod instead
|
||||
*/
|
||||
public function getCurrentAccompanyingPeriod()
|
||||
public function getCurrentAccompanyingPeriod() : AccompanyingPeriod
|
||||
{
|
||||
return $this->getOpenedAccompanyingPeriod();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
* Get AccompanyingPeriods Collection
|
||||
*/
|
||||
public function getAccompanyingPeriods()
|
||||
public function getAccompanyingPeriods() : Collection
|
||||
{
|
||||
return $this->accompanyingPeriods;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the accompanying periods of a give person with the
|
||||
* chronological order.
|
||||
*
|
||||
* @return AccompanyingPeriod[]
|
||||
* Get the accompanying periods of a give person with the chronological order.
|
||||
*/
|
||||
public function getAccompanyingPeriodsOrdered()
|
||||
public function getAccompanyingPeriodsOrdered() : array
|
||||
{
|
||||
$periods = $this->getAccompanyingPeriods()->toArray();
|
||||
|
||||
@@ -406,11 +401,9 @@ class Person implements HasCenterInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the person is opened
|
||||
*
|
||||
* @return boolean
|
||||
* Check if the person is opened
|
||||
*/
|
||||
public function isOpen()
|
||||
public function isOpen() : bool
|
||||
{
|
||||
foreach ($this->getAccompanyingPeriods() as $period) {
|
||||
if ($period->isOpen()) {
|
||||
@@ -1051,4 +1044,15 @@ class Person implements HasCenterInterface
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getFullnameCanonical() : string
|
||||
{
|
||||
return $this->fullnameCanonical;
|
||||
}
|
||||
|
||||
public function setFullnameCanonical($fullnameCanonical) : Person
|
||||
{
|
||||
$this->fullnameCanonical = $fullnameCanonical;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user