<?php
namespace App\Domain\Entity\PointOfInterest;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\Link;
use ApiPlatform\Metadata\Post;
use App\Domain\Entity\Attribute;
use App\Domain\Entity\Behavior\Identifiable;
use DateTime;
use Gedmo\Timestampable\Traits\Timestampable;
/**
* Class RevisionAttribute
*
* @package App\Domain\Entity\PointOfInterest
*/
#[ApiResource(
operations: [
new Get(),
new GetCollection(filters: ['revision_attribute.search_filter']),
new Post(),
],
normalizationContext: ['groups' => ['revision_attribute_read']],
denormalizationContext: ['groups' => ['revision_attribute_write']]
)]
#[ApiResource(
uriTemplate: '/revisions/{uuid}/revision_attributes',
operations: [
new GetCollection(),
],
uriVariables: [
'uuid' => new Link(fromProperty: 'attributes', fromClass: Revision::class),
]
)]
class RevisionAttribute
{
use Identifiable;
use Timestampable;
public function __construct(
public Attribute $attribute,
public Revision $revision,
public ?float $detail = null,
public ?bool $isFree = null,
public ?string $remoteId = null,
public ?DateTime $zhistUpdate = null,
) {}
public function getCategory(): string
{
return $this->attribute->category->code;
}
public function getIsFree(): bool
{
return $this->isFree ?? false;
}
public function getSection(): string
{
return $this->attribute->section;
}
}