src/Domain/Entity/PointOfInterest/RevisionAttribute.php line 38

Open in your IDE?
  1. <?php
  2. namespace App\Domain\Entity\PointOfInterest;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\GetCollection;
  6. use ApiPlatform\Metadata\Link;
  7. use ApiPlatform\Metadata\Post;
  8. use App\Domain\Entity\Attribute;
  9. use App\Domain\Entity\Behavior\Identifiable;
  10. use DateTime;
  11. use Gedmo\Timestampable\Traits\Timestampable;
  12. /**
  13.  * Class RevisionAttribute
  14.  *
  15.  * @package App\Domain\Entity\PointOfInterest
  16.  */
  17. #[ApiResource(
  18.     operations: [
  19.         new Get(),
  20.         new GetCollection(filters: ['revision_attribute.search_filter']),
  21.         new Post(),
  22.     ],
  23.     normalizationContext: ['groups' => ['revision_attribute_read']],
  24.     denormalizationContext: ['groups' => ['revision_attribute_write']]
  25. )]
  26. #[ApiResource(
  27.     uriTemplate'/revisions/{uuid}/revision_attributes',
  28.     operations: [
  29.         new GetCollection(),
  30.     ],
  31.     uriVariables: [
  32.         'uuid' => new Link(fromProperty'attributes'fromClassRevision::class),
  33.     ]
  34. )]
  35. class RevisionAttribute
  36. {
  37.     use Identifiable;
  38.     use Timestampable;
  39.     public function __construct(
  40.         public Attribute $attribute,
  41.         public Revision $revision,
  42.         public ?float $detail null,
  43.         public ?bool $isFree null,
  44.         public ?string $remoteId null,
  45.         public ?DateTime $zhistUpdate null,
  46.     ) {}
  47.     public function getCategory(): string
  48.     {
  49.         return $this->attribute->category->code;
  50.     }
  51.     public function getIsFree(): bool
  52.     {
  53.         return $this->isFree ?? false;
  54.     }
  55.     public function getSection(): string
  56.     {
  57.         return $this->attribute->section;
  58.     }
  59. }