46 lines
1.0 KiB
PHP
46 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace KupShop\ComponentsBundle\Entity;
|
|
|
|
use KupShop\KupShopBundle\Util\StringUtil;
|
|
|
|
class CollectionProduct
|
|
{
|
|
public function __construct(
|
|
public readonly int $id,
|
|
private readonly \Product $product,
|
|
) {
|
|
}
|
|
|
|
public function getTitle(): string
|
|
{
|
|
return $this->product->title;
|
|
}
|
|
|
|
public function getParamTitle(int $id_parameter): ?string
|
|
{
|
|
return $this->product->param[$id_parameter]['value'] ?? null;
|
|
}
|
|
|
|
public function getUrl(): string
|
|
{
|
|
return path('products', ['id' => $this->product->id, 'name' => StringUtil::slugify($this->product->title)]);
|
|
}
|
|
|
|
public function getThumbnail(): ?Thumbnail
|
|
{
|
|
if ($this->product->photoId > 0) {
|
|
return new Thumbnail((string) $this->product->photoId, $this->product->photoDescr, $this->product->photoDateUpdate);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public function getProductParams(): array
|
|
{
|
|
return $this->product->param ?? [];
|
|
}
|
|
}
|