src/Entity/JournalPageTranslation.php line 32
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM,
Doctrine\DBAL\Types\Types;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Metadata\ApiProperty,
ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\Get;
use App\Entity\Trait\IdTrait,
App\Entity\Trait\UuidTrait,
App\Entity\Trait\TimestampableTrait,
App\Entity\Trait\TranslationTrait,
App\Entity\Trait\SEOTrait,
App\Entity\Interface\TranslationInterface,
App\Repository\JournalPageTranslationRepository;
use App\Attribute\Sanitizeable,
App\Enum\Language;
#[ApiResource(
security: 'is_granted("' . Journal::class . '")',
operations: [ new Get() ],
extraProperties: ['standard_put' => false],
)]
#[ORM\Entity(repositoryClass: JournalPageTranslationRepository::class)]
class JournalPageTranslation implements TranslationInterface
{
use IdTrait,
UuidTrait,
TimestampableTrait,
TranslationTrait,
SEOTrait;
#[ApiProperty(description: 'Title')]
#[Groups(['read', 'write'])]
#[ORM\Column(type: Types::STRING, length: 511, nullable: true)]
private ?string $title = null;
#[ApiProperty(description: 'Description')]
#[Groups(['read:' . self::class, 'write'])]
#[Sanitizeable]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
// in old ejournals sometimes there was description despite linking content from other field,
// this content was no displayed but still existed in database, maybe if they unlink field?
#[ApiProperty(description: 'Old description besides linked text')]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $ignoredDescription = null;
#[ApiProperty(description: 'Slug')]
#[Groups(['read:' . self::class, 'write'])]
#[Gedmo\Slug(separator: '-', style: 'default', updatable: true, fields: ['title'], unique: false)]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $slug = null;
public function __construct(JournalPage $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 setIgnoredDescription(?string $ignoredDescription): self
{
$this->ignoredDescription = $ignoredDescription;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function clone(JournalPage $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;
}
}