Update Podcast to add branding config; update PodcastEpisode to add season and episode numbers.
This commit is contained in:
parent
c84522105d
commit
c881a28be4
|
@ -42,6 +42,13 @@ final class Podcast
|
|||
#[OA\Property]
|
||||
public string $description_short;
|
||||
|
||||
#[OA\Property(
|
||||
description: "An array containing podcast-specific branding configuration",
|
||||
type: "array",
|
||||
items: new OA\Items()
|
||||
)]
|
||||
public array $branding_config;
|
||||
|
||||
#[OA\Property]
|
||||
public string $language;
|
||||
|
||||
|
|
|
@ -33,6 +33,12 @@ final class PodcastEpisode
|
|||
#[OA\Property]
|
||||
public bool $explicit = false;
|
||||
|
||||
#[OA\Property]
|
||||
public ?int $season_number = null;
|
||||
|
||||
#[OA\Property]
|
||||
public ?int $episode_number = null;
|
||||
|
||||
#[OA\Property]
|
||||
public int $created_at;
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ final class PodcastApiGenerator
|
|||
$return->description = $record->getDescription();
|
||||
$return->description_short = Strings::truncateText($return->description, 200);
|
||||
|
||||
$return->branding_config = $record->getBrandingConfig()->toArray();
|
||||
|
||||
$return->language = $record->getLanguage();
|
||||
try {
|
||||
$locale = $request->getCustomization()->getLocale();
|
||||
|
|
|
@ -41,6 +41,9 @@ final class PodcastEpisodeApiGenerator
|
|||
$return->description_short = Strings::truncateText($return->description, 100);
|
||||
|
||||
$return->explicit = $record->getExplicit();
|
||||
$return->season_number = $record->getSeasonNumber();
|
||||
$return->episode_number = $record->getEpisodeNumber();
|
||||
|
||||
$return->created_at = $record->getCreatedAt();
|
||||
$return->publish_at = $record->getPublishAt();
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity\Migration;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
|
||||
final class Version20240421094525 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Expand podcast database fields.';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE podcast ADD branding_config JSON DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE podcast_episode ADD season_number INT NOT NULL, ADD episode_number INT NOT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE podcast DROP branding_config');
|
||||
$this->addSql('ALTER TABLE podcast_episode DROP season_number, DROP episode_number');
|
||||
}
|
||||
|
||||
}
|
|
@ -52,6 +52,9 @@ class Podcast implements Interfaces\IdentifiableEntityInterface
|
|||
#[Assert\NotBlank]
|
||||
protected string $description;
|
||||
|
||||
#[ORM\Column(type: 'json', nullable: true)]
|
||||
protected ?array $branding_config = null;
|
||||
|
||||
#[ORM\Column(length: 2)]
|
||||
#[Assert\NotBlank]
|
||||
protected string $language;
|
||||
|
@ -147,6 +150,24 @@ class Podcast implements Interfaces\IdentifiableEntityInterface
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getBrandingConfig(): PodcastBrandingConfiguration
|
||||
{
|
||||
return new PodcastBrandingConfiguration((array)$this->branding_config);
|
||||
}
|
||||
|
||||
public function setBrandingConfig(
|
||||
PodcastBrandingConfiguration|array $brandingConfig,
|
||||
bool $forceOverwrite = false
|
||||
): void {
|
||||
if (is_array($brandingConfig)) {
|
||||
$brandingConfig = new PodcastBrandingConfiguration(
|
||||
$forceOverwrite ? $brandingConfig : array_merge((array)$this->branding_config, $brandingConfig)
|
||||
);
|
||||
}
|
||||
|
||||
$this->branding_config = $brandingConfig->toArray();
|
||||
}
|
||||
|
||||
public function getLanguage(): string
|
||||
{
|
||||
return $this->language;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
class PodcastBrandingConfiguration extends AbstractStationConfiguration
|
||||
{
|
||||
|
||||
}
|
|
@ -52,6 +52,12 @@ class PodcastEpisode implements IdentifiableEntityInterface
|
|||
#[ORM\Column]
|
||||
protected bool $explicit;
|
||||
|
||||
#[ORM\Column]
|
||||
protected ?int $season_number;
|
||||
|
||||
#[ORM\Column]
|
||||
protected ?int $episode_number;
|
||||
|
||||
#[ORM\Column]
|
||||
protected int $created_at;
|
||||
|
||||
|
@ -151,6 +157,30 @@ class PodcastEpisode implements IdentifiableEntityInterface
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function getSeasonNumber(): ?int
|
||||
{
|
||||
return $this->season_number;
|
||||
}
|
||||
|
||||
public function setSeasonNumber(?int $season_number): self
|
||||
{
|
||||
$this->season_number = $season_number;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEpisodeNumber(): ?int
|
||||
{
|
||||
return $this->episode_number;
|
||||
}
|
||||
|
||||
public function setEpisodeNumber(?int $episode_number): self
|
||||
{
|
||||
$this->episode_number = $episode_number;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): int
|
||||
{
|
||||
return $this->created_at;
|
||||
|
|
Loading…
Reference in New Issue