Category unactive implies all the reasons with this category as unactive - refs #622

This commit is contained in:
Marc Ducobu 2015-10-01 16:35:10 +02:00
parent 0ecfcae98b
commit 744a68f195
2 changed files with 24 additions and 5 deletions

View File

@ -20,6 +20,8 @@
namespace Chill\ActivityBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
/**
* ActivityReasonCategory
*/
@ -40,13 +42,19 @@ class ActivityReasonCategory
*/
private $active;
/** @var ArrayCollection array of ActivityReason */
private $reasons;
public function __construct()
{
$this->reasons = new ArrayCollection();
}
public function __toString()
{
return 'blop';
return 'ActivityReasonCategory('.$this->getName('x').')';
}
/**
* Get id
*
@ -95,16 +103,23 @@ class ActivityReasonCategory
}
/**
* Set active
* Declare a category as active (or not). When a category is set
* as unactive, all the reason have this entity as category is also
* set as unactive
*
* @param boolean $active
*
* @return ActivityReasonCategory
*/
public function setActive($active)
{
if($this->active !== $active && !$active) {
foreach ($this->reasons as $reason) {
$reason->setActive($active);
}
}
$this->active = $active;
return $this;
}

View File

@ -12,4 +12,8 @@ Chill\ActivityBundle\Entity\ActivityReasonCategory:
type: json_array
active:
type: boolean
oneToMany:
reasons:
targetEntity: Chill\ActivityBundle\Entity\ActivityReason
mappedBy: category
lifecycleCallbacks: { }