src/Entity/BlockContent.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Controller\Action\BlockContentCreateOrUpdateActionController;
  4. use App\Controller\Action\BlockContentGetActionController;
  5. use App\Repository\BlockContentRepository;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use ApiPlatform\Metadata\ApiResource;
  9. use ApiPlatform\Metadata\Get;
  10. use ApiPlatform\Metadata\Put;
  11. use phpDocumentor\Reflection\Types\Boolean;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. #[ORM\Table(name'BLOCK_CONTENT')]
  14. #[ORM\Entity(repositoryClassBlockContentRepository::class)]
  15. #[ApiResource(
  16.     operations: [
  17.         new Get(
  18.             name'block_content_item',
  19.             uriTemplate'/block_contents/{name}',
  20.             controllerBlockContentGetActionController::class,
  21.             uriVariables: [
  22.                 'name' => ['from_class' => BlockContent::class, 'from_property' => 'name']
  23.             ],
  24.             writefalse,
  25.             readfalse
  26.         ),
  27.         new Put(
  28.             name'block_content_create_or_update',
  29.             uriTemplate'/block_contents/{name}',
  30.             controllerBlockContentCreateOrUpdateActionController::class,
  31.             uriVariables: [
  32.                 'name' => ['from_class' => BlockContent::class, 'from_property' => 'name']
  33.             ],
  34.             readfalse,
  35.             writefalse,
  36.         )
  37.     ]
  38. )]
  39. class BlockContent
  40. {
  41.     #[ORM\Id]
  42.     #[ORM\GeneratedValue]
  43.     #[ORM\Column]
  44.     #[Groups(['block_content.list''block_content.get'])]
  45.     private ?int $id null;
  46.     #[ORM\Column(length255uniquetrue)]
  47.     #[Groups(['block_content.list''block_content.get''block_content.create''block_content.update'])]
  48.     private ?string $name null;
  49.     #[ORM\Column(typeTypes::TEXT)]
  50.     #[Groups(['block_content.get''block_content.create''block_content.update'])]
  51.     private ?string $content null;
  52.     #[ORM\Column(length255)]
  53.     #[Groups(['block_content.list''block_content.get''block_content.create''block_content.update'])]
  54.     private ?string $type null;
  55.     #[ORM\Column(length255nullabletrue)]
  56.     #[Groups(['block_content.list''block_content.get''block_content.create''block_content.update'])]
  57.     private ?string $color null;
  58.     #[ORM\Column(length255nullabletrue)]
  59.     #[Groups(['block_content.list''block_content.get''block_content.create''block_content.update'])]
  60.     private ?string $icon null;
  61.     #[ORM\Column(typeTypes::BOOLEAN)]
  62.     #[Groups(['block_content.list''block_content.get''block_content.update'])]
  63.     private bool $isActive true;
  64.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  65.     #[Groups(['block_content.list''block_content.get'])]
  66.     private ?\DateTimeInterface $createdAt null;
  67.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  68.     #[Groups(['block_content.list''block_content.get'])]
  69.     private ?\DateTimeInterface $updatedAt null;
  70.     public function __construct()
  71.     {
  72.         $this->createdAt = new \DateTime();
  73.     }
  74.     public function getId(): ?int
  75.     {
  76.         return $this->id;
  77.     }
  78.     public function getName(): ?string
  79.     {
  80.         return $this->name;
  81.     }
  82.     public function setName(string $name): static
  83.     {
  84.         $this->name $name;
  85.         return $this;
  86.     }
  87.     public function getContent(): ?string
  88.     {
  89.         return $this->content;
  90.     }
  91.     public function setContent(string $content): static
  92.     {
  93.         $this->content $content;
  94.         return $this;
  95.     }
  96.     public function getType(): ?string
  97.     {
  98.         return $this->type;
  99.     }
  100.     public function setType(string $type): static
  101.     {
  102.         $this->type $type;
  103.         return $this;
  104.     }
  105.     public function getCreatedAt(): ?\DateTimeInterface
  106.     {
  107.         return $this->createdAt;
  108.     }
  109.     public function setCreatedAt(\DateTimeInterface $createdAt): static
  110.     {
  111.         $this->createdAt $createdAt;
  112.         return $this;
  113.     }
  114.     public function getUpdatedAt(): ?\DateTimeInterface
  115.     {
  116.         return $this->updatedAt;
  117.     }
  118.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  119.     {
  120.         $this->updatedAt $updatedAt;
  121.         return $this;
  122.     }
  123.     public function getColor(): ?string
  124.     {
  125.         return $this->color;
  126.     }
  127.     public function setColor(?string $color): static
  128.     {
  129.         $this->color $color;
  130.         return $this;
  131.     }
  132.     public function getIcon(): ?string
  133.     {
  134.         return $this->icon;
  135.     }
  136.     public function setIcon(?string $icon): static
  137.     {
  138.         $this->icon $icon;
  139.         return $this;
  140.     }
  141.     public function isActive(): bool
  142.     {
  143.         return $this->isActive;
  144.     }
  145.     public function getIsActive(): bool
  146.     {
  147.         return $this->isActive;
  148.     }
  149.     public function setIsActive(bool $isActive): static
  150.     {
  151.         $this->isActive $isActive;
  152.         return $this;
  153.     }
  154.     #[ORM\PreUpdate]
  155.     public function setUpdatedAtValue(): void
  156.     {
  157.         $this->updatedAt = new \DateTime();
  158.     }
  159. }