From 7992f09aea50c69d65cf9378a589a4ed4f7e9287 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Tue, 1 Jun 2021 17:14:05 +0200 Subject: [PATCH] Ajout SocialAction & SocialIssues to Activity --- .../ChillActivityBundle/Entity/Activity.php | 66 +++++++++++++++++++ .../migrations/Version20210528161250.php | 39 +++++++++++ 2 files changed, 105 insertions(+) create mode 100644 src/Bundle/ChillActivityBundle/migrations/Version20210528161250.php diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index e76bf338a..6b69bdf8e 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -21,8 +21,11 @@ namespace Chill\ActivityBundle\Entity; use Chill\DocStoreBundle\Entity\Document; +use Chill\DocStoreBundle\Entity\StoredObject; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use Chill\PersonBundle\Entity\AccompanyingPeriod; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; +use Chill\PersonBundle\Entity\SocialWork\SocialIssue; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Doctrine\ORM\Mapping as ORM; use Chill\MainBundle\Entity\Scope; @@ -100,6 +103,19 @@ class Activity implements HasCenterInterface, HasScopeInterface */ private Collection $reasons; + /** + * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialIssue") + * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialissue") + */ + private $socialIssues; + + /** + * @ORM\ManyToMany(targetEntity="Chill\PersonBundle\Entity\SocialWork\SocialAction") + * @ORM\JoinTable(name="chill_activity_activity_chill_person_socialaction") + */ + private $socialActions; + + /** * @ORM\ManyToOne(targetEntity="Chill\ActivityBundle\Entity\ActivityType") */ @@ -167,6 +183,8 @@ class Activity implements HasCenterInterface, HasScopeInterface $this->thirdParties = new ArrayCollection(); $this->documents = new ArrayCollection(); $this->users = new ArrayCollection(); + $this->socialIssues = new ArrayCollection(); + $this->socialActions = new ArrayCollection(); } public function getId(): ?int @@ -258,6 +276,54 @@ class Activity implements HasCenterInterface, HasScopeInterface return $this; } + public function getSocialIssues(): Collection + { + return $this->socialIssues; + } + + public function addSocialIssue(SocialIssue $socialIssue): self + { + if (!$this->socialIssues->contains($socialIssue)) { + $this->socialIssues[] = $socialIssue; + } + + return $this; + } + + public function removeSocialIssue(SocialIssue $socialIssue): self + { + $this->socialIssues->removeElement($socialIssue); + + return $this; + } + + /** + * @return Collection|SocialAction[] + */ + public function getSocialActions(): Collection + { + return $this->socialActions; + } + + public function addSocialAction(SocialAction $socialAction): self + { + if (!$this->socialActions->contains($socialAction)) { + $this->socialActions[] = $socialAction; + } + + return $this; + } + + public function removeSocialAction(SocialAction $socialAction): self + { + $this->socialActions->removeElement($socialAction); + + return $this; + } + + + + public function setType(ActivityType $type): self { $this->type = $type; diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20210528161250.php b/src/Bundle/ChillActivityBundle/migrations/Version20210528161250.php new file mode 100644 index 000000000..8eaf7e1a4 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20210528161250.php @@ -0,0 +1,39 @@ +addSql('CREATE TABLE chill_activity_activity_chill_person_socialissue (activity_id INT NOT NULL, socialissue_id INT NOT NULL, PRIMARY KEY(activity_id, socialissue_id))'); + $this->addSql('CREATE INDEX IDX_3DA33F2681C06096 ON chill_activity_activity_chill_person_socialissue (activity_id)'); + $this->addSql('CREATE INDEX IDX_3DA33F26A549916C ON chill_activity_activity_chill_person_socialissue (socialissue_id)'); + $this->addSql('CREATE TABLE chill_activity_activity_chill_person_socialaction (activity_id INT NOT NULL, socialaction_id INT NOT NULL, PRIMARY KEY(activity_id, socialaction_id))'); + $this->addSql('CREATE INDEX IDX_548F1AD881C06096 ON chill_activity_activity_chill_person_socialaction (activity_id)'); + $this->addSql('CREATE INDEX IDX_548F1AD83DC32179 ON chill_activity_activity_chill_person_socialaction (socialaction_id)'); + $this->addSql('ALTER TABLE chill_activity_activity_chill_person_socialissue ADD CONSTRAINT FK_3DA33F2681C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_activity_activity_chill_person_socialissue ADD CONSTRAINT FK_3DA33F26A549916C FOREIGN KEY (socialissue_id) REFERENCES chill_person_social_issue (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_activity_activity_chill_person_socialaction ADD CONSTRAINT FK_548F1AD881C06096 FOREIGN KEY (activity_id) REFERENCES activity (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_activity_activity_chill_person_socialaction ADD CONSTRAINT FK_548F1AD83DC32179 FOREIGN KEY (socialaction_id) REFERENCES chill_person_social_action (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP TABLE chill_activity_activity_chill_person_socialissue'); + $this->addSql('DROP TABLE chill_activity_activity_chill_person_socialaction'); + } +}