mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-05 15:29:50 +00:00
create dashboard item entity
This commit is contained in:
parent
b5f7f578da
commit
f4c08ee0d7
@ -792,10 +792,10 @@ class ChillMainExtension extends Extension implements
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
/* [
|
[
|
||||||
'class' => \Chill\MainBundle\Entity\DashboardItem::class,
|
'class' => \Chill\MainBundle\Entity\DashboardItem::class,
|
||||||
'controller' => \Chill\MainBundle\Controller\DashboardApiController::class,
|
'controller' => \Chill\MainBundle\Controller\DashboardApiController::class,
|
||||||
'name' => 'news-item',
|
'name' => 'dashboard-item',
|
||||||
'base_path' => '/api/1.0/main/dashboard-item',
|
'base_path' => '/api/1.0/main/dashboard-item',
|
||||||
'base_role' => 'ROLE_USER',
|
'base_role' => 'ROLE_USER',
|
||||||
'actions' => [
|
'actions' => [
|
||||||
@ -812,7 +812,7 @@ class ChillMainExtension extends Extension implements
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
],*/
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
53
src/Bundle/ChillMainBundle/Entity/DashboardItem.php
Normal file
53
src/Bundle/ChillMainBundle/Entity/DashboardItem.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\MainBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Entity
|
||||||
|
*
|
||||||
|
* @ORM\Table(name="chill_main_dashboard_item")
|
||||||
|
*/
|
||||||
|
class DashboardItem
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @ORM\Id
|
||||||
|
*
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
*
|
||||||
|
* @ORM\Column(type="integer")
|
||||||
|
*
|
||||||
|
* @Serializer\Groups({"dashboardItem:read", "read"})
|
||||||
|
*/
|
||||||
|
private ?int $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\Column(type="string")
|
||||||
|
*
|
||||||
|
* @Serializer\Groups({"dashboardItem:read", "read"})
|
||||||
|
*
|
||||||
|
* @Assert\NotNull
|
||||||
|
*/
|
||||||
|
private string $type = '';
|
||||||
|
|
||||||
|
public function getId(): ?int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getType(): string
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setType(string $type): self
|
||||||
|
{
|
||||||
|
$this->type = $type;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
@ -58,13 +58,13 @@ class NewsItem implements TrackCreationInterface, TrackUpdateInterface
|
|||||||
private string $content = '';
|
private string $content = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string")
|
* @ORM\OneToOne (targetEntity="DashboardItem", inversedBy="newsItem")
|
||||||
*
|
*
|
||||||
* @groups({"write", "read"})
|
* @groups({"write", "read"})
|
||||||
*
|
*
|
||||||
* @Assert\NotNull
|
* @Assert\NotNull
|
||||||
*/
|
*/
|
||||||
private string $type = 'news';
|
private ?DashboardItem $dashboardItem = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="date_immutable", nullable=false)
|
* @ORM\Column(type="date_immutable", nullable=false)
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Chill\Migrations\Main;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create dashboard item entity and link to news item
|
||||||
|
*/
|
||||||
|
final class Version20231108115104 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return 'Create dashboard item entity and link to news item';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
$this->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');
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user