<?php
namespace App\Entity\Tag;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\Tag\TagRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Ramsey\Uuid\Doctrine\UuidGenerator;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=TagRepository::class)
*
* @ApiResource(
* attributes={
* "normalization_context"={"groups"={
* "Tag:output",
* "Tag:io",
* "Blog:output",
* }},
* "denormalization_context"={"groups"={
* "Tag:input",
* "Tag:io",
* }}
* },
* collectionOperations={},
* itemOperations={},
* )
*
* @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"blog" = "BlogTag"})
*/
abstract class Tag
{
/**
* Hook timestampable behavior
* updates createdAt, updatedAt fields
*/
use TimestampableEntity;
/**
* @ORM\Id
* @ORM\Column(type="uuid", unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class=UuidGenerator::class)
* @SerializedName("id")
* @ApiProperty(identifier=true)
* @Assert\Uuid()
* @Groups({
* "Tag:output",
* "Blog:output",
* })
*/
protected $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "Tag:output",
* "Blog:output",
* })
*/
private ?string $title;
public function getId(): ?string
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function __toString(): string
{
return $this->title;
}
/**
* @SerializedName("created_at")
* @Groups({
* "Tag:output",
* "Blog:output",
* })
* @return string
*/
public function getSerializeCreatedAt(): string
{
return $this->getCreatedAt()->format('Y-m-d H:i:s');
}
}