src/Entity/IndexationDatabase.php line 56
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiProperty;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM,
Doctrine\Common\Collections\ArrayCollection;
use ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\Get,
ApiPlatform\Metadata\GetCollection,
ApiPlatform\Metadata\Post,
ApiPlatform\Metadata\Put,
ApiPlatform\Metadata\Delete,
ApiPlatform\Metadata\ApiFilter,
ApiPlatform\Doctrine\Orm\Filter\SearchFilter,
ApiPlatform\Doctrine\Orm\Filter\BooleanFilter,
ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
use App\Entity\Trait\IdTrait,
App\Entity\Trait\UuidTrait,
App\Entity\Trait\OrdStatTrait,
App\Entity\Trait\TimestampableTrait,
App\Entity\Trait\TranslatableTrait,
App\Entity\Trait\Languages\SiteLanguagesTrait,
App\Entity\Interface\TranslatableInterface,
App\Entity\Interface\OrdStatableInterface,
App\Entity\Interface\LanguageableInterface,
App\Repository\IndexationDatabaseRepository,
App\Enum\Language;
use Symfony\Component\Serializer\Annotation\Groups;
#[ApiResource(
description: 'Indexation databases',
normalizationContext: ['groups' => [
'read',
'read:' . self::class,
'read:' . self::class . 'Translation'
]],
denormalizationContext: ['groups' => ['write']],
security: 'is_granted("' . self::class . '")',
order: ['ord' => 'desc'],
operations: [
new GetCollection(),
new Post(),
new Get(),
new Put(),
new Delete(),
],
extraProperties: ['standard_put' => false],
)]
#[ApiFilter(SearchFilter::class, properties: ['translations.title' => 'partial', 'nativeTitle' => 'partial'])]
#[ApiFilter(BooleanFilter::class, properties: ['stat'])]
#[ApiFilter(OrderFilter::class, properties: ['nativeTitle', 'ord'])]
#[ORM\Entity(repositoryClass: IndexationDatabaseRepository::class)]
class IndexationDatabase implements TranslatableInterface, OrdStatableInterface, LanguageableInterface
{
use IdTrait,
UuidTrait,
OrdStatTrait,
TimestampableTrait,
TranslatableTrait,
SiteLanguagesTrait;
#[ApiProperty(description: 'Title')]
#[Groups(['read', 'write'])]
#[ORM\Column(length: 255, nullable: true)]
private ?string $title = null;
#[ApiProperty(description: 'Show in journal list')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
protected bool $showInJournalList = false;
public function __construct(?array $languages)
{
$this->setUuid();
$this->translations = new ArrayCollection();
$this->setLanguages($languages ?? Language::DEFAULT_SITE);
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
$this->nativeTitle = $title;
return $this;
}
public function isShowInJournalList(): bool
{
return $this->showInJournalList;
}
public function setShowInJournalList(bool $showInJournalList): self
{
$this->showInJournalList = $showInJournalList;
return $this;
}
}