diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 6db465cc1..4355e0f56 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -792,10 +792,10 @@ class ChillMainExtension extends Extension implements ], ], ], -/* [ + [ 'class' => \Chill\MainBundle\Entity\DashboardItem::class, 'controller' => \Chill\MainBundle\Controller\DashboardApiController::class, - 'name' => 'news-item', + 'name' => 'dashboard-item', 'base_path' => '/api/1.0/main/dashboard-item', 'base_role' => 'ROLE_USER', 'actions' => [ @@ -812,7 +812,7 @@ class ChillMainExtension extends Extension implements ], ], ], - ],*/ + ], ], ]); } diff --git a/src/Bundle/ChillMainBundle/Entity/DashboardItem.php b/src/Bundle/ChillMainBundle/Entity/DashboardItem.php new file mode 100644 index 000000000..d849407bc --- /dev/null +++ b/src/Bundle/ChillMainBundle/Entity/DashboardItem.php @@ -0,0 +1,53 @@ +id; + } + + public function getType(): string + { + return $this->type; + } + + public function setType(string $type): self + { + $this->type = $type; + + return $this; + } +} diff --git a/src/Bundle/ChillMainBundle/Entity/NewsItem.php b/src/Bundle/ChillMainBundle/Entity/NewsItem.php index b35076101..c58acf48e 100644 --- a/src/Bundle/ChillMainBundle/Entity/NewsItem.php +++ b/src/Bundle/ChillMainBundle/Entity/NewsItem.php @@ -58,13 +58,13 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface private string $content = ''; /** - * @ORM\Column(type="string") + * @ORM\OneToOne (targetEntity="DashboardItem", inversedBy="newsItem") * * @groups({"write", "read"}) * * @Assert\NotNull */ - private string $type = 'news'; + private ?DashboardItem $dashboardItem = null; /** * @ORM\Column(type="date_immutable", nullable=false) diff --git a/src/Bundle/ChillMainBundle/migrations/Version20231108115104.php b/src/Bundle/ChillMainBundle/migrations/Version20231108115104.php new file mode 100644 index 000000000..d33001598 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20231108115104.php @@ -0,0 +1,39 @@ +addSql('CREATE SEQUENCE chill_main_dashboard_item_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_main_dashboard_item (id INT NOT NULL, type VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + $this->addSql('ALTER TABLE chill_main_news ADD dashboardItem_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_main_news DROP type'); + $this->addSql('ALTER TABLE chill_main_news ADD CONSTRAINT FK_96922AFBCBDA857A FOREIGN KEY (dashboardItem_id) REFERENCES chill_main_dashboard_item (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_96922AFBCBDA857A ON chill_main_news (dashboardItem_id)'); + $this->addSql('ALTER TABLE chill_main_notification ALTER addressesemails DROP DEFAULT'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_news DROP CONSTRAINT FK_96922AFBCBDA857A'); + $this->addSql('DROP SEQUENCE chill_main_dashboard_item_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_main_dashboard_item'); + $this->addSql('ALTER TABLE chill_main_news ADD type VARCHAR(255) NOT NULL'); + $this->addSql('ALTER TABLE chill_main_news DROP dashboardItem_id'); + } +}