Cockpit integration

This commit is contained in:
2024-11-07 21:34:32 +01:00
parent d3eccf99f0
commit a4b336b3fd
8 changed files with 153 additions and 41 deletions

View File

@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Application\Models;
use Exception;
use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\Type;
@@ -13,39 +14,95 @@ class Article
#[SerializedName('authors')]
#[Type('array<' . Author::class . '>')]
protected array $authors;
protected ?array $authors = null;
#[SerializedName('headline')]
#[Type('string')]
protected string $headline;
protected ?string $headline = null;
#[SerializedName('excerpt')]
#[Type('string')]
protected string $excerpt;
protected ?string $excerpt = null;
#[SerializedName('image')]
#[Type(Image::class)]
protected Image $image;
protected ?Image $image = null;
#[SerializedName('text')]
#[Type('string')]
protected string $text;
protected ?string $text = null;
/**
* Return the title / headline.
*
* @return string
* @return string|null
*/
public function getTitle(): string {
public function getTitle(): string|null
{
return $this->headline;
}
/**
* Return the text / article body text.
*
* @return string
* @return string|null
*/
public function getText(): string {
public function getText(): string|null
{
return $this->text;
}
/**
* Get the excerpt / teaser text.
*
* @return string|null
*/
public function getExcerpt(): string|null
{
return $this->excerpt;
}
public function getImage(): Image|null
{
return $this->image;
}
public function getTeaserData(): array
{
return [
'headline' => $this->getHeadline(),
'kicker' => $this->getKicker(),
'excerpt' => $this->getExcerpt(),
'teaserImage' => $this->getTeaserImage(),
'url' => $this->getUrl(),
];
}
private function getIdentifier(): string
{
return $this->metaId;
}
private function getHeadline(): ?string
{
return $this->headline;
}
private function getKicker(): ?string
{
return $this->excerpt;
}
/**
* @throws Exception
*/
private function getTeaserImage(): array
{
return $this->image->getTeaserData();
}
public function getUrl(): string
{
return '/article/test_article-' . $this->getIdentifier();
}
}