src/Entity/ReciprocalRelationshipType.php line 50
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM,
Doctrine\DBAL\Types\Types;
use Symfony\Component\Serializer\Annotation\Groups,
Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Metadata\ApiResource,
ApiPlatform\Metadata\ApiProperty,
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\Interface\OrdStatableInterface,
App\Repository\ReciprocalRelationshipTypeRepository;
use App\Enum\RelationshipType;
#[ApiResource(
description: 'Reciprocal relationship types',
normalizationContext: ['groups' => ['read', 'read:' . self::class]],
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: ['title' => 'partial'])]
#[ApiFilter(BooleanFilter::class, properties: ['stat'])]
#[ApiFilter(OrderFilter::class, properties: ['ord'])]
#[ORM\Entity(repositoryClass: ReciprocalRelationshipTypeRepository::class)]
class ReciprocalRelationshipType implements OrdStatableInterface
{
use IdTrait,
UuidTrait,
OrdStatTrait,
TimestampableTrait;
#[ApiProperty(description: 'Title')]
#[Groups(['read', 'write'])]
#[Assert\NotBlank]
#[ORM\Column(type: Types::STRING, length: 255, unique: true)]
private string $title;
#[ApiProperty(description: 'Description')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ApiProperty(description: 'Type')]
#[Groups(['read:' . self::class, 'write'])]
#[ORM\Column(
type: Types::STRING,
enumType: RelationshipType::class,
length: 255,
options: ['default' => RelationshipType::INTRA_WORK]
)]
private RelationshipType $type = RelationshipType::INTRA_WORK;
public function __construct(string $title, ?string $description, RelationshipType $type)
{
$this->setUuid();
$this->title = $title;
$this->description = $description;
$this->type = $type;
$this->createdAt = new \DateTimeImmutable();
$this->updatedAt = new \DateTimeImmutable();
}
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getType(): RelationshipType
{
return $this->type;
}
public function setType(RelationshipType $type): self
{
$this->type = $type;
return $this;
}
}