Files
2025-08-02 16:30:27 +02:00

223 lines
3.9 KiB
PHP

<?php
namespace KupShop\CommentsBundle;
use KupShop\AdminBundle\Util\LegacyAdminCredentials;
use KupShop\KupShopBundle\Template\ArrayAccess;
class Comment extends ArrayAccess
{
public const TYPE_PRODUCT = 'product';
public const TYPE_ARTICLE = 'article';
public const STATUS_UNCONFIRMED = 0;
public const STATUS_CONFIRMED = 1;
public const STATUS_TOP = 2;
public const SOLVED_NO = 0;
public const SOLVED_YES = 1;
protected $id;
protected $id_language;
protected $id_parent;
protected $id_product;
protected $id_article;
protected $id_user;
protected $id_admin;
protected $content;
protected $status;
protected $solved;
protected $date;
protected $parent;
protected $children = [];
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getId(): int
{
return $this->id;
}
public function setIdLanguage(string $languageId): self
{
$this->id_language = $languageId;
return $this;
}
public function getIdLanguage(): string
{
return $this->id_language;
}
public function setIdParent(?int $parentId): self
{
$this->id_parent = $parentId;
return $this;
}
public function getIdParent(): ?int
{
return $this->id_parent;
}
public function setIdProduct(?int $productId): self
{
$this->id_product = $productId;
return $this;
}
public function getIdProduct(): ?int
{
return $this->id_product;
}
public function setIdArticle(?int $articleId): self
{
$this->id_article = $articleId;
return $this;
}
public function getIdArticle(): ?int
{
return $this->id_article;
}
public function setIdUser(?int $id_user): self
{
$this->id_user = $id_user;
return $this;
}
public function getIdUser(): ?int
{
return $this->id_user;
}
public function setIdAdmin(?int $id_admin): self
{
$this->id_admin = $id_admin;
return $this;
}
public function getIdAdmin(): ?int
{
return $this->id_admin;
}
public function setContent(string $content): self
{
$this->content = $content;
return $this;
}
public function getContent(): string
{
return $this->content;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getStatus(): int
{
return $this->status;
}
public function setSolved(int $solved): self
{
$this->solved = $solved;
return $this;
}
public function getSolved(): int
{
return $this->solved;
}
public function setDateAdd(string $date): self
{
$this->date = new \DateTime($date);
return $this;
}
public function getDateAdd(): \DateTime
{
return $this->date;
}
public function setParent(?Comment $parent): self
{
$this->parent = $parent;
return $this;
}
public function getParent(): ?Comment
{
return $this->parent;
}
public function setChildren(array $children): self
{
$this->children = $children;
return $this;
}
public function getChildren(): array
{
return $this->children;
}
public function getChildrenCount(): int
{
$count = count($this->getChildren());
foreach ($this->getChildren() as $child) {
$count += $child->getChildrenCount();
}
return $count;
}
public function getUser(): ?\User
{
return \User::createFromId($this->id_user);
}
public function getAdmin(): ?array
{
return $this->id_admin ? LegacyAdminCredentials::getAdminById($this->id_admin) : null;
}
}