<?php
declare(strict_types=1);
namespace App\Domain\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\Put;
use App\Domain\Entity\Behavior\Identifiable;
use App\Domain\Entity\Translation\OffmapCategoryTranslation;
use DateTime;
use Gedmo\SoftDeleteable\Traits\SoftDeleteable;
use Gedmo\Timestampable\Traits\Timestampable;
use Locastic\ApiPlatformTranslationBundle\Model\AbstractTranslatable;
use Locastic\ApiPlatformTranslationBundle\Model\TranslationInterface;
#[ApiResource(
operations : [
new Delete(security: "is_granted('ROLE_ADMIN')"),
new GetCollection(filters: ['offmap_category.search_filter', 'offmap_category.query_filter']),
new Get(),
new Post(normalizationContext: ['groups' => ['translations']], security: "is_granted('ROLE_ADMIN')"),
new Put(normalizationContext: ['groups' => ['translations']], security: "is_granted('ROLE_ADMIN')"),
],
normalizationContext : ['groups' => ['offmap_category_read']],
denormalizationContext: ['groups' => ['offmap_category_write']],
filters : ['translation.groups']
)]
class OffmapCategory extends AbstractTranslatable
{
use Identifiable;
use SoftDeleteable;
use Timestampable;
public ?string $remoteId = null;
public ?DateTime $zhistUpdate = null;
public function __construct()
{
parent::__construct();
}
public function getTranslationType(): OffmapCategoryTranslation
{
return $this->getTranslation();
}
public function getName(): ?string
{
return $this->getTranslationType()->getName();
}
public function setName(?string $name): void
{
$this->getTranslationType()->setName($name);
}
public function createTranslation(): TranslationInterface
{
return new OffmapCategoryTranslation();
}
}