fix bugs in accompanying periods

ref #11
This commit is contained in:
2016-05-17 10:02:45 +02:00
parent 8b98e8a4b6
commit ce7c149c35
12 changed files with 355 additions and 77 deletions

View File

@@ -95,6 +95,7 @@ class Person implements HasCenterInterface {
/**
* @var boolean
* @deprecated
*/
private $proxyAccompanyingPeriodOpenState = false; //TO-DELETE ?
@@ -168,11 +169,12 @@ class Person implements HasCenterInterface {
}
/**
* Return the opened accompanying period.
*
* @return null|AccompanyingPeriod
* @return AccompanyingPeriod
*/
public function getCurrentAccompanyingPeriod() {
if ($this->proxyAccompanyingPeriodOpenState === false) {
public function getOpenedAccompanyingPeriod() {
if ($this->isOpen() === false) {
return null;
}
@@ -183,6 +185,17 @@ class Person implements HasCenterInterface {
}
}
/**
* Returns the opened accompanying period.
*
* @return AccompanyingPeriod
* @deprecated since 1.1 use `getOpenedAccompanyingPeriod instead
*/
public function getCurrentAccompanyingPeriod()
{
return $this->getOpenedAccompanyingPeriod();
}
/**
*
* @return \Doctrine\Common\Collections\ArrayCollection
@@ -230,8 +243,20 @@ class Person implements HasCenterInterface {
return $periods;
}
public function isOpen() {
return $this->proxyAccompanyingPeriodOpenState;
/**
* check if the person is opened
*
* @return boolean
*/
public function isOpen()
{
foreach ($this->getAccompanyingPeriods() as $period) {
if ($period->isOpen()) {
return true;
}
}
return false;
}
/**