Stakeholder). */ public const JOIN_TABLE_NAME = 'mt3s_mp_program_task_raci_stakeholders'; private ?int $id = null; private ?Task $task = null; private RaciRole $role = RaciRole::Responsible; /** * @var Collection */ private Collection $stakeholders; /** * Display order within the task's RACI list, from 0. */ private int $position = 0; public function __construct() { $this->stakeholders = new ArrayCollection(); } public function __clone() { $this->id = null; $this->task = null; $this->stakeholders = new ArrayCollection(); } public static function loadMetadata(OrmClassMetadata $metadata): void { $builder = new ClassMetadataBuilder($metadata); $builder->setTable(self::TABLE_NAME) ->setCustomRepositoryClass(TaskRaciRepository::class); $builder->addId(); $builder->createManyToOne('task', Task::class) ->inversedBy('raci') ->addJoinColumn('task_id', 'id', false, false, 'CASCADE') ->build(); $metadata->mapField([ 'fieldName' => 'role', 'type' => Types::STRING, 'length' => 20, 'enumType' => RaciRole::class, 'options' => ['default' => RaciRole::Responsible->value], ]); $builder->createManyToMany('stakeholders', Stakeholder::class) ->setJoinTable(self::JOIN_TABLE_NAME) ->addJoinColumn('raci_id', 'id', false, false, 'CASCADE') ->addInverseJoinColumn('stakeholder_id', 'id', false, false, 'CASCADE') ->build(); $builder->createField('position', Types::INTEGER) ->option('default', 0) ->build(); } public function getId(): ?int { return $this->id; } public function getTask(): ?Task { return $this->task; } public function setTask(?Task $task): static { $this->task = $task; return $this; } public function getRole(): RaciRole { return $this->role; } public function setRole(RaciRole $role): static { $this->role = $role; return $this; } /** * @return Collection */ public function getStakeholders(): Collection { return $this->stakeholders; } public function addStakeholder(Stakeholder $stakeholder): static { if (!$this->stakeholders->contains($stakeholder)) { $this->stakeholders->add($stakeholder); } return $this; } public function removeStakeholder(Stakeholder $stakeholder): static { $this->stakeholders->removeElement($stakeholder); return $this; } public function getPosition(): int { return $this->position; } public function setPosition(?int $position): static { $this->position = $position ?? 0; return $this; } }