src_legacy/Tionvel/WorkflowBundle/Entity/WorkflowUnitConfig.php line 12

Open in your IDE?
  1. <?php
  2. namespace Tionvel\WorkflowBundle\Entity;
  3. use App\Entity\Office;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass="Tionvel\WorkflowBundle\Repository\WorkflowUnitConfigRepository")
  8. */
  9. class WorkflowUnitConfig
  10. {
  11. /**
  12. * @var int
  13. * @ORM\Id @ORM\Column(type="integer")
  14. * @ORM\GeneratedValue(strategy="AUTO")
  15. */
  16. private $id;
  17. /**
  18. * @var Office
  19. * @ORM\OneToOne(targetEntity="App\Entity\Office")
  20. * @ORM\JoinColumn(onDelete="CASCADE")
  21. */
  22. private $unit;
  23. /**
  24. * @var boolean
  25. * @ORM\Column(type="boolean")
  26. */
  27. private $enabled = false;
  28. /**
  29. * @var ArrayCollection
  30. * @ORM\OneToMany(
  31. * targetEntity="Tionvel\WorkflowBundle\Entity\WorkflowUnitWorkflow",
  32. * mappedBy="unitConfig",
  33. * indexBy="workflowId",
  34. * fetch="EAGER",
  35. * cascade={"persist"},
  36. * orphanRemoval=true
  37. * )
  38. */
  39. private $configs;
  40. public function __construct()
  41. {
  42. $this->configs = new ArrayCollection();
  43. }
  44. public static function create(Office $office)
  45. {
  46. $self = new self;
  47. $self->setUnit($office);
  48. $self->setEnabled(true);
  49. return $self;
  50. }
  51. public function getId(): int
  52. {
  53. return $this->id;
  54. }
  55. public function getUnit(): Office
  56. {
  57. return $this->unit;
  58. }
  59. public function setUnit(Office $unit)
  60. {
  61. $this->unit = $unit;
  62. }
  63. public function isEnabled(): bool
  64. {
  65. return $this->enabled;
  66. }
  67. public function setEnabled(bool $enable)
  68. {
  69. $this->enabled = $enable;
  70. }
  71. public function getConfigs()
  72. {
  73. return $this->configs;
  74. }
  75. public function setConfigs(ArrayCollection $configs)
  76. {
  77. $this->configs = $configs;
  78. }
  79. public function addConfig(WorkflowUnitWorkflow $config)
  80. {
  81. if (!isset($this->configs[$config->getWorkflowId()])) {
  82. $config->setUnitConfig($this);
  83. $this->configs[$config->getWorkflowId()] = $config;
  84. }
  85. }
  86. public function removeConfig(WorkflowUnitWorkflow $config)
  87. {
  88. if (isset($this->configs[$config->getWorkflowId()])) {
  89. $this->configs->removeElement($config);
  90. }
  91. }
  92. }