diff --git a/src/Bundle/ChillEventBundle/Entity/Event.php b/src/Bundle/ChillEventBundle/Entity/Event.php index c065ed94f..28fcf6092 100644 --- a/src/Bundle/ChillEventBundle/Entity/Event.php +++ b/src/Bundle/ChillEventBundle/Entity/Event.php @@ -71,6 +71,10 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter #[ORM\ManyToOne(targetEntity: EventType::class)] private ?EventType $type = null; + #[ORM\ManyToMany(targetEntity: EventTheme::class)] + #[ORM\JoinTable('chill_event_eventtheme')] + private Collection $themes; + #[ORM\Embedded(class: CommentEmbeddable::class, columnPrefix: 'comment_')] private CommentEmbeddable $comment; @@ -96,6 +100,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter $this->participations = new ArrayCollection(); $this->documents = new ArrayCollection(); $this->comment = new CommentEmbeddable(); + $this->themes = new ArrayCollection(); } /** @@ -126,10 +131,27 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter return $this; } + public function getThemes(): Collection + { + return $this->themes; + } + + public function addTheme(EventTheme $theme): self + { + $this->themes->add($theme); + + return $this; + } + + public function removeTheme(EventTheme $theme): void + { + $this->themes->removeElement($theme); + } + /** * @return Center */ - public function getCenter() + public function getCenter(): ?Center { return $this->center; } @@ -137,7 +159,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * @return Scope */ - public function getCircle() + public function getCircle(): ?Scope { return $this->circle; } @@ -147,7 +169,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter * * @return \DateTime */ - public function getDate() + public function getDate(): ?\DateTime { return $this->date; } @@ -157,7 +179,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter * * @return int */ - public function getId() + public function getId(): ?int { return $this->id; } @@ -172,7 +194,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter * * @return string */ - public function getName() + public function getName(): ?string { return $this->name; } @@ -202,7 +224,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter * * @return Scope */ - public function getScope() + public function getScope(): ?Scope { return $this->getCircle(); } @@ -210,7 +232,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * @return EventType */ - public function getType() + public function getType(): ?EventType { return $this->type; } @@ -218,7 +240,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter /** * Remove participation. */ - public function removeParticipation(Participation $participation) + public function removeParticipation(Participation $participation): void { $this->participations->removeElement($participation); } diff --git a/src/Bundle/ChillEventBundle/migrations/Version20250429062911.php b/src/Bundle/ChillEventBundle/migrations/Version20250429062911.php new file mode 100644 index 000000000..9f931eaa1 --- /dev/null +++ b/src/Bundle/ChillEventBundle/migrations/Version20250429062911.php @@ -0,0 +1,35 @@ +addSql('CREATE TABLE chill_event_eventtheme (event_id INT NOT NULL, eventtheme_id INT NOT NULL, PRIMARY KEY(event_id, eventtheme_id))'); + $this->addSql('CREATE INDEX IDX_8D75029771F7E88B ON chill_event_eventtheme (event_id)'); + $this->addSql('CREATE INDEX IDX_8D750297A81D3C55 ON chill_event_eventtheme (eventtheme_id)'); + $this->addSql('ALTER TABLE chill_event_eventtheme ADD CONSTRAINT FK_8D75029771F7E88B FOREIGN KEY (event_id) REFERENCES chill_event_event (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_event_eventtheme ADD CONSTRAINT FK_8D750297A81D3C55 FOREIGN KEY (eventtheme_id) REFERENCES chill_event_event_theme (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_event_eventtheme DROP CONSTRAINT FK_8D75029771F7E88B'); + $this->addSql('ALTER TABLE chill_event_eventtheme DROP CONSTRAINT FK_8D750297A81D3C55'); + $this->addSql('DROP TABLE chill_event_eventtheme'); + } +}