mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 06:26:15 +00:00
Category unactive implies all the reasons with this category as unactive - refs #622
This commit is contained in:
parent
0ecfcae98b
commit
744a68f195
@ -20,6 +20,8 @@
|
|||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivityReasonCategory
|
* ActivityReasonCategory
|
||||||
*/
|
*/
|
||||||
@ -40,13 +42,19 @@ class ActivityReasonCategory
|
|||||||
*/
|
*/
|
||||||
private $active;
|
private $active;
|
||||||
|
|
||||||
|
/** @var ArrayCollection array of ActivityReason */
|
||||||
|
private $reasons;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->reasons = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return 'blop';
|
return 'ActivityReasonCategory('.$this->getName('x').')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id
|
* 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
|
* @param boolean $active
|
||||||
*
|
|
||||||
* @return ActivityReasonCategory
|
* @return ActivityReasonCategory
|
||||||
*/
|
*/
|
||||||
public function setActive($active)
|
public function setActive($active)
|
||||||
{
|
{
|
||||||
|
if($this->active !== $active && !$active) {
|
||||||
|
foreach ($this->reasons as $reason) {
|
||||||
|
$reason->setActive($active);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->active = $active;
|
$this->active = $active;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,4 +12,8 @@ Chill\ActivityBundle\Entity\ActivityReasonCategory:
|
|||||||
type: json_array
|
type: json_array
|
||||||
active:
|
active:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
oneToMany:
|
||||||
|
reasons:
|
||||||
|
targetEntity: Chill\ActivityBundle\Entity\ActivityReason
|
||||||
|
mappedBy: category
|
||||||
lifecycleCallbacks: { }
|
lifecycleCallbacks: { }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user