<?phpnamespace Tionvel\WorkflowBundle\Entity;use App\Entity\Office;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\ORM\Mapping as ORM;/** * @ORM\Entity(repositoryClass="Tionvel\WorkflowBundle\Repository\WorkflowUnitConfigRepository") */class WorkflowUnitConfig{ /** * @var int * @ORM\Id @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @var Office * @ORM\OneToOne(targetEntity="App\Entity\Office") * @ORM\JoinColumn(onDelete="CASCADE") */ private $unit; /** * @var boolean * @ORM\Column(type="boolean") */ private $enabled = false; /** * @var ArrayCollection * @ORM\OneToMany( * targetEntity="Tionvel\WorkflowBundle\Entity\WorkflowUnitWorkflow", * mappedBy="unitConfig", * indexBy="workflowId", * fetch="EAGER", * cascade={"persist"}, * orphanRemoval=true * ) */ private $configs; public function __construct() { $this->configs = new ArrayCollection(); } public static function create(Office $office) { $self = new self; $self->setUnit($office); $self->setEnabled(true); return $self; } public function getId(): int { return $this->id; } public function getUnit(): Office { return $this->unit; } public function setUnit(Office $unit) { $this->unit = $unit; } public function isEnabled(): bool { return $this->enabled; } public function setEnabled(bool $enable) { $this->enabled = $enable; } public function getConfigs() { return $this->configs; } public function setConfigs(ArrayCollection $configs) { $this->configs = $configs; } public function addConfig(WorkflowUnitWorkflow $config) { if (!isset($this->configs[$config->getWorkflowId()])) { $config->setUnitConfig($this); $this->configs[$config->getWorkflowId()] = $config; } } public function removeConfig(WorkflowUnitWorkflow $config) { if (isset($this->configs[$config->getWorkflowId()])) { $this->configs->removeElement($config); } }}