* * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ namespace Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity( * repositoryClass="Chill\CustomFieldsBundle\EntityRepository\CustomFieldLongChoice\OptionRepository") * @ORM\Table(name="custom_field_long_choice_options") * * @author Julien Fastré */ class Option { /** * @var integer * * @ORM\Id * @ORM\Column(name="id", type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var string * @ORM\Column(type="string", length=15) */ private $key; /** * A json representation of text (multilingual) * * @var array * @ORM\Column(type="json_array") */ private $text; /** * @var Collection * @ORM\OneToMany( * targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option", * mappedBy="parent") */ private $children; /** * @var Option * @ORM\ManyToOne( * targetEntity="Chill\CustomFieldsBundle\Entity\CustomFieldLongChoice\Option", * inversedBy="children") * @ORM\JoinColumn(nullable=true) */ private $parent; /** * @var string * @ORM\Column(type="string", length=50, name="internal_key") */ private $internalKey = ''; /** * @var boolean * @ORM\Column(type="boolean") */ private $active = true; /** * @return int */ public function getId() { return $this->id; } /** * @return string */ public function getKey() { return $this->key; } /** * @return array */ public function getText() { return $this->text; } /** * @return Collection */ public function getChildren() { return $this->children; } /** * @return Option */ public function getParent() { return $this->parent; } /** * @param $key * @return $this */ public function setKey($key) { $this->key = $key; return $this; } /** * @param array $text * @return $this */ public function setText(array $text) { $this->text = $text; return $this; } /** * @param Option|null $parent * @return $this */ public function setParent(Option $parent = null) { $this->parent = $parent; $this->key = $parent->getKey(); return $this; } /** * * @return boolean */ public function hasParent() { return $this->parent === NULL ? false : true; } /** * @return string */ public function getInternalKey() { return $this->internalKey; } /** * @return bool */ public function isActive() { return $this->active; } /** * @return bool */ public function getActive() { return $this->isActive(); } /** * @param $internal_key * @return $this */ public function setInternalKey($internal_key) { $this->internalKey = $internal_key; return $this; } /** * @param $active * @return $this */ public function setActive($active) { $this->active = $active; return $this; } }