src/Entity/JournalIssueTranslation.php line 38
<?php
namespace App\Entity;
use App\Entity\Trait\JournalUniqueSlugTrait;
use Doctrine\Common\Collections\ArrayCollection;
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\Interface\ThumbableInterface,
App\Entity\Trait\IdTrait,
App\Entity\Trait\UuidTrait,
App\Entity\Trait\TimestampableTrait,
App\Entity\Trait\TranslationTrait,
App\Entity\Trait\SlugTrait,
App\Entity\Trait\Media\ThumbableTrait,
App\Entity\Trait\Media\SetMediaTrait,
App\Entity\Trait\Media\SetImageThumbableTrait;
use App\Enum\Language,
App\Attribute\Sanitizeable,
App\Repository\JournalIssueTranslationRepository;
use App\Validator\Constraints as CustomAssert;
#[ApiResource(
security: 'is_granted("' . Journal::class . '")',
operations: [ new Get() ],
extraProperties: ['standard_put' => false],
)]
#[ORM\Entity(repositoryClass: JournalIssueTranslationRepository::class)]
class JournalIssueTranslation implements TranslationInterface, ThumbableInterface
{
use IdTrait,
UuidTrait,
TimestampableTrait,
TranslationTrait,
JournalUniqueSlugTrait,
ThumbableTrait,
SetImageThumbableTrait,
SetMediaTrait;
#[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: 'Cover', writableLink: false)]
#[Groups(['read:' . self::class, 'write'])]
#[CustomAssert\ValidMediaMimeType(types: ['image/*'])]
#[ORM\ManyToOne(targetEntity: Media::class, cascade: ['persist', 'remove'])]
#[ORM\JoinColumn(onDelete: 'set null')]
private ?Media $cover = null;
#[ApiProperty(description: 'Cover alt')]
#[Groups(['read:' . self::class, 'write'])]
#[Sanitizeable]
#[ORM\Column(type: Types::STRING, length: 255, nullable: true)]
private ?string $coverAlt = null;
#[ApiProperty(description: 'Funding description')]
#[Groups(['read:' . self::class, 'write'])]
#[Sanitizeable]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $fundingDescription = null;
#[ApiProperty(description: 'Copyrights')]
#[Groups(['read:' . self::class, 'write'])]
#[Sanitizeable]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $copyrights = null;
#[ApiProperty(description: 'Description')]
#[Groups(['read:' . self::class, 'write'])]
#[Sanitizeable]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ApiProperty(description: 'Additional info')]
#[Groups(['read:' . self::class, 'write'])]
#[Sanitizeable]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $additionalInfo = null;
#[ApiProperty(description: 'Indexed content')]
#[Groups(['read:' . self::class, 'write'])]
#[Sanitizeable]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $indexedContent = 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(JournalIssue $parent, Language $lang)
{
$this->setUuid();
$this->parent = $parent;
$this->lang = $lang;
$this->uniqueKey = sprintf('%s_%s', $parent->getParent()->getId(), $lang->value);
$this->thumbs = new ArrayCollection();
$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;
}
#[Groups(['read'])]
public function getFullTitle(): ?string
{
/** @var JournalIssue $parent */
$parent = $this->parent;
$title = $parent->getVolume()
? sprintf(
"%s - %s",
$parent->getVolume()->readTranslation($this->lang, 'title'),
$this->title
) : $this->title;
return sprintf(
"%s - %s",
$parent->getParent()->readTranslation($this->lang, 'title'),
$title
);
}
public function getSubtitle(): ?string
{
return $this->subtitle;
}
public function setSubtitle(?string $subtitle): self
{
$this->subtitle = $subtitle;
return $this;
}
public function getCover(): ?Media
{
return $this->cover;
}
public function setCover(?Media $cover): self
{
return $this->setImageThumbable('cover', $cover);
}
public function getCoverAlt(): ?string
{
return $this->coverAlt;
}
public function setCoverAlt(?string $coverAlt): self
{
$this->coverAlt = $coverAlt;
return $this;
}
public function getFundingDescription(): ?string
{
return $this->fundingDescription;
}
public function setFundingDescription(?string $fundingDescription): self
{
$this->fundingDescription = $fundingDescription;
return $this;
}
public function getCopyrights(): ?string
{
return $this->copyrights;
}
public function setCopyrights(?string $copyrights): self
{
$this->copyrights = $copyrights;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getAdditionalInfo(): ?string
{
return $this->additionalInfo;
}
public function setAdditionalInfo(?string $additionalInfo): self
{
$this->additionalInfo = $additionalInfo;
return $this;
}
public function setIndexedContent(?string $indexedContent): self
{
$this->indexedContent = $indexedContent;
return $this;
}
public function getIndexedContent(): ?string
{
return $this->indexedContent;
}
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(JournalIssue $parent): self
{
$clone = clone $this;
$clone->id = null;
$clone->setUuid();
if ($clone->cover) {
$clone->cover = $this->cover->clone();
$clone->cover->setRelated(self::class . ':' . $clone->uuid->toString());
}
$clone->parent = $parent;
$clone->parent->addTranslation($clone);
$clone->createdAt = new \DateTimeImmutable();
$clone->updatedAt = new \DateTimeImmutable();
return $clone;
}
}