diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php index 4bff7a3f5..8c27d0c3e 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStep.php @@ -32,6 +32,12 @@ class EntityWorkflowStep */ private string $accessKey; + /** + * @ORM\ManyToMany(targetEntity=User::class) + * @ORM\JoinTable(name="chill_main_workflow_entity_step_cc_user") + */ + private Collection $ccUser; + /** * @ORM\Column(type="text", options={"default": ""}) */ @@ -114,6 +120,7 @@ class EntityWorkflowStep public function __construct() { + $this->ccUser = new ArrayCollection(); $this->destUser = new ArrayCollection(); $this->destUserByAccessKey = new ArrayCollection(); $this->accessKey = bin2hex(openssl_random_pseudo_bytes(32)); @@ -128,6 +135,15 @@ class EntityWorkflowStep return $this; } + public function addCcUser(User $user): self + { + if (!$this->ccUser->contains($user)) { + $this->ccUser[] = $user; + } + + return $this; + } + public function addDestUser(User $user): self { if (!$this->destUser->contains($user)) { @@ -167,6 +183,11 @@ class EntityWorkflowStep ); } + public function getCcUser(): Collection + { + return $this->ccUser; + } + public function getComment(): string { return $this->comment; @@ -261,6 +282,13 @@ class EntityWorkflowStep return true; } + public function removeCcUser(User $user): self + { + $this->ccUser->removeElement($user); + + return $this; + } + public function removeDestEmail(string $email): self { $this->destEmail = array_filter($this->destEmail, static function (string $existing) use ($email) { diff --git a/src/Bundle/ChillMainBundle/migrations/Version20230321134155.php b/src/Bundle/ChillMainBundle/migrations/Version20230321134155.php new file mode 100644 index 000000000..801d49e58 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20230321134155.php @@ -0,0 +1,32 @@ +addSql('ALTER TABLE chill_main_workflow_entity_step_cc_user DROP CONSTRAINT FK_9FC79037E6AF9D4'); + $this->addSql('ALTER TABLE chill_main_workflow_entity_step_cc_user DROP CONSTRAINT FK_9FC7903A76ED395'); + $this->addSql('DROP TABLE chill_main_workflow_entity_step_cc_user'); + } + + public function getDescription(): string + { + return 'Add cc User to workflow step'; + } + + public function up(Schema $schema): void + { + $this->addSql('CREATE TABLE chill_main_workflow_entity_step_cc_user (entityworkflowstep_id INT NOT NULL, user_id INT NOT NULL, PRIMARY KEY(entityworkflowstep_id, user_id))'); + $this->addSql('CREATE INDEX IDX_9FC79037E6AF9D4 ON chill_main_workflow_entity_step_cc_user (entityworkflowstep_id)'); + $this->addSql('CREATE INDEX IDX_9FC7903A76ED395 ON chill_main_workflow_entity_step_cc_user (user_id)'); + $this->addSql('ALTER TABLE chill_main_workflow_entity_step_cc_user ADD CONSTRAINT FK_9FC79037E6AF9D4 FOREIGN KEY (entityworkflowstep_id) REFERENCES chill_main_workflow_entity_step (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_main_workflow_entity_step_cc_user ADD CONSTRAINT FK_9FC7903A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } +}