* * @ORM\OneToMany( * targetEntity="Chill\ActivityBundle\Entity\ActivityReason", * mappedBy="category") */ private Collection $reasons; /** * ActivityReasonCategory constructor. */ public function __construct() { $this->reasons = new ArrayCollection(); } public function __toString(): string { return 'ActivityReasonCategory('.$this->getName('x').')'; } /** * Get active. * * @return bool */ public function getActive() { return $this->active; } /** * Get id. * * @return int */ public function getId() { return $this->id; } /** * Get name. * * @param mixed|null $locale * * @return array */ public function getName($locale = null) { if ($locale) { if (isset($this->name[$locale])) { return $this->name[$locale]; } foreach ($this->name as $name) { if (!empty($name)) { return $name; } } return ''; } return $this->name; } /** * 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. * * @return ActivityReasonCategory */ public function setActive(bool $active) { if ($this->active !== $active && !$active) { foreach ($this->reasons as $reason) { $reason->setActive($active); } } $this->active = $active; return $this; } /** * Set name. * * @param array $name * * @return ActivityReasonCategory */ public function setName($name) { $this->name = $name; return $this; } }