src/Entity/JournalVolumeTranslation.php line 30
<?php
namespace App\Entity;
use App\Entity\Trait\JournalUniqueSlugTrait;
use Doctrine\ORM\Mapping as ORM,
Doctrine\DBAL\Types\Types;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Metadata\ApiProperty,
ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\Get;
use App\Entity\Interface\TranslationInterface,
App\Entity\Trait\IdTrait,
App\Entity\Trait\UuidTrait,
App\Entity\Trait\TimestampableTrait,
App\Entity\Trait\TranslationTrait;
use App\Enum\Language,
App\Attribute\Sanitizeable,
App\Repository\JournalVolumeTranslationRepository;
#[ApiResource(
security: 'is_granted("' . Journal::class . '")',
operations: [ new Get() ],
extraProperties: ['standard_put' => false],
)]
#[ORM\Entity(repositoryClass: JournalVolumeTranslationRepository::class)]
class JournalVolumeTranslation implements TranslationInterface
{
use IdTrait,
UuidTrait,
TimestampableTrait,
TranslationTrait,
JournalUniqueSlugTrait;
#[ApiProperty(description: 'Title')]
#[Groups(['read', 'write'])]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $title = null;
#[ApiProperty(description: 'Subtitle')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $subtitle = null;
#[ApiProperty(description: 'Funding description')]
#[Groups(['read:' . self::class, 'write'])]
#[Sanitizeable]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $fundingDescription = null;
#[ApiProperty(description: 'Meta title')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $metaTitle = null;
#[ApiProperty(description: 'Meta description')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $metaDescription = null;
#[ApiProperty(description: 'Meta keywords')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $metaKeywords = null;
public function __construct(JournalVolume $parent, Language $lang)
{
$this->setUuid();
$this->parent = $parent;
$this->lang = $lang;
$this->uniqueKey = sprintf('%s_%s', $parent->getParent()->getId(), $lang->value);
$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 getFullTitle(): ?string
{
/** @var JournalVolume $parent */
$parent = $this->parent;
return sprintf(
"%s - %s",
$parent->getParent()->readTranslation($this->lang, 'title'),
$this->title
);
}
public function getSubtitle(): ?string
{
return $this->subtitle;
}
public function setSubtitle(?string $subtitle): self
{
$this->subtitle = $subtitle;
return $this;
}
public function getFundingDescription(): ?string
{
return $this->fundingDescription;
}
public function setFundingDescription(?string $fundingDescription): self
{
$this->fundingDescription = $fundingDescription;
return $this;
}
public function getMetaTitle(): ?string
{
return $this->metaTitle;
}
public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription(?string $metaDescription): self
{
$this->metaDescription = $metaDescription;
return $this;
}
public function getMetaKeywords(): ?string
{
return $this->metaKeywords;
}
public function setMetaKeywords(?string $metaKeywords): self
{
$this->metaKeywords = $metaKeywords;
return $this;
}
public function clone(JournalVolume $parent): self
{
$clone = clone $this;
$clone->id = null;
$clone->setUuid();
$clone->parent = $parent;
$clone->parent->addTranslation($clone);
$clone->createdAt = new \DateTimeImmutable();
$clone->updatedAt = new \DateTimeImmutable();
return $clone;
}
}