From 66df8f785097b74bf651a875a5642490f709bd83 Mon Sep 17 00:00:00 2001 From: Buster Neece Date: Thu, 25 Apr 2024 10:19:37 -0500 Subject: [PATCH] Add "is_enabled" flag to Podcasts. --- src/Entity/Api/Podcast.php | 3 ++ .../ApiGenerator/PodcastApiGenerator.php | 2 ++ .../Migration/Version20240425151151.php | 30 +++++++++++++++++++ src/Entity/Podcast.php | 13 ++++++++ 4 files changed, 48 insertions(+) create mode 100644 src/Entity/Migration/Version20240425151151.php diff --git a/src/Entity/Api/Podcast.php b/src/Entity/Api/Podcast.php index 9d7eb2a5b..e29b16c77 100644 --- a/src/Entity/Api/Podcast.php +++ b/src/Entity/Api/Podcast.php @@ -42,6 +42,9 @@ final class Podcast #[OA\Property] public string $description_short; + #[OA\Property] + public bool $is_enabled = true; + #[OA\Property( description: "An array containing podcast-specific branding configuration", type: "array", diff --git a/src/Entity/ApiGenerator/PodcastApiGenerator.php b/src/Entity/ApiGenerator/PodcastApiGenerator.php index 8ded89a40..4ac6c67b2 100644 --- a/src/Entity/ApiGenerator/PodcastApiGenerator.php +++ b/src/Entity/ApiGenerator/PodcastApiGenerator.php @@ -48,6 +48,8 @@ final class PodcastApiGenerator $return->description = $record->getDescription(); $return->description_short = Strings::truncateText($return->description, 200); + $return->is_enabled = $record->isEnabled(); + $return->branding_config = $record->getBrandingConfig()->toArray(); $return->language = $record->getLanguage(); diff --git a/src/Entity/Migration/Version20240425151151.php b/src/Entity/Migration/Version20240425151151.php new file mode 100644 index 000000000..f464a520f --- /dev/null +++ b/src/Entity/Migration/Version20240425151151.php @@ -0,0 +1,30 @@ +addSql('ALTER TABLE podcast ADD is_enabled TINYINT(1) NOT NULL AFTER description'); + + $this->addSql(<<<'SQL' + UPDATE podcast + SET is_enabled=1 + SQL); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE podcast DROP is_enabled'); + } +} diff --git a/src/Entity/Podcast.php b/src/Entity/Podcast.php index 759db2de0..5ec88131e 100644 --- a/src/Entity/Podcast.php +++ b/src/Entity/Podcast.php @@ -52,6 +52,9 @@ class Podcast implements Interfaces\IdentifiableEntityInterface #[Assert\NotBlank] protected string $description; + #[ORM\Column] + protected bool $is_enabled = true; + #[ORM\Column(type: 'json', nullable: true)] protected ?array $branding_config = null; @@ -150,6 +153,16 @@ class Podcast implements Interfaces\IdentifiableEntityInterface return $this; } + public function isEnabled(): bool + { + return $this->is_enabled; + } + + public function setIsEnabled(bool $is_enabled): void + { + $this->is_enabled = $is_enabled; + } + public function getBrandingConfig(): PodcastBrandingConfiguration { return new PodcastBrandingConfiguration((array)$this->branding_config);