src/Entity/PageTranslation.php line 24
<?php
namespace App\Entity;
use App\Repository\PageTranslationRepository;
use Doctrine\ORM\Mapping as ORM,
Doctrine\DBAL\Types\Types;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Metadata\ApiProperty;
use App\Entity\Trait\IdTrait,
App\Entity\Trait\UuidTrait,
App\Entity\Trait\TimestampableTrait,
App\Entity\Trait\TranslationTrait,
App\Entity\Trait\SEOTrait,
App\Entity\Trait\SlugTrait,
App\Entity\Interface\TranslationInterface;
use App\Attribute\Sanitizeable,
App\Enum\Language;
#[ORM\Entity(repositoryClass: PageTranslationRepository::class)]
class PageTranslation implements TranslationInterface
{
use IdTrait,
UuidTrait,
TimestampableTrait,
TranslationTrait,
SEOTrait,
SlugTrait;
#[ApiProperty(description: 'Title')]
#[Groups(['read', 'write'])]
#[ORM\Column(type: Types::STRING, length: 511, nullable: true)]
private ?string $title = null;
#[ApiProperty(description: 'Description')]
#[Groups(['read', 'write'])]
#[Sanitizeable]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
public function __construct(Page $parent, Language $lang)
{
$this->setUuid();
$this->parent = $parent;
$this->lang = $lang;
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
$parent->addTranslation($this);
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function clone(Page $parent): self
{
$clone = clone $this;
$clone->id = null;
$clone->setUuid();
$clone->slug = null;
$clone->parent = $parent;
$clone->parent->addTranslation($clone);
$clone->createdAt = new \DateTimeImmutable();
$clone->updatedAt = new \DateTimeImmutable();
return $clone;
}
}