Add event theme property to event entity

This commit is contained in:
Julie Lenaerts 2025-04-29 10:02:52 +02:00
parent ad46f606a3
commit 055765956a
2 changed files with 65 additions and 8 deletions

View File

@ -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);
}

View File

@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Event;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20250429062911 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add themes property to event';
}
public function up(Schema $schema): void
{
$this->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');
}
}