Initial Commit

This commit is contained in:
khaccount committed 2026-05-18 14:46:25 +02:00
1 parent 4f495177e4
commit b6d2142214
166 files changed
+13952 -178

No files matched your search

@@ -0,0 +1,80 @@
<?php
declare(strict_types=1);
namespace Evomedien\Vitec\Domain\Model\Dto;
/**
* DTO for Product List Content Element in JSON output
*/
class ProductListContentElement implements \JsonSerializable
{
protected array $products = [];
protected array $settings = [];
public function setProducts(array $products): void
{
$this->products = $products;
}
public function setSettings(array $settings): void
{
$this->settings = $settings;
}
public function jsonSerialize(): array
{
$productsData = [];
foreach ($this->products as $product) {
$productsData[] = [
'uid' => $product->getUid(),
'title' => $product->getTitle(),
'subtitle' => $product->getSubtitle(),
'teaser' => $product->getTeaser(),
'description' => $product->getDescription(),
'slug' => $product->getSlug(),
'categories' => $this->serializeCategories($product->getCategories()),
'image' => $this->serializeImage($product->getProductimage()),
];
}
return [
'products' => $productsData,
'settings' => $this->settings,
];
}
protected function serializeCategories($categories): array
{
$categoriesData = [];
if ($categories) {
foreach ($categories as $category) {
$categoriesData[] = [
'uid' => $category->getUid(),
'title' => $category->getTitle(),
];
}
}
return $categoriesData;
}
protected function serializeImage($images): ?array
{
if (!$images || $images->count() === 0) {
return null;
}
$imageObject = $images->current();
return [
'uid' => $imageObject->getUid(),
'url' => $imageObject->getOriginalResource()->getPublicUrl(),
'title' => $imageObject->getTitle(),
'alternative' => $imageObject->getAlternative(),
'description' => $imageObject->getDescription(),
];
}
}