src/Entity/WebsiteParams/GameParams.php line 52

Open in your IDE?
  1. <?php
  2. namespace App\Entity\WebsiteParams;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  6. use ApiPlatform\Core\Annotation\ApiResource;
  7. use App\Controller\Api\WebsiteParams\GetAllPublicGameParams;
  8. use App\Entity\MediaObject\MediaGameParams;
  9. use App\Repository\WebsiteParams\GameParamsRepository;
  10. use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. use Symfony\Component\Serializer\Annotation\SerializedName;
  15. use App\Validator\Constraints as AppAssert;
  16. /**
  17.  * @ORM\Entity(repositoryClass=GameParamsRepository::class)
  18.  *
  19.  * @ApiResource(
  20.  *     attributes={
  21.  *          "normalization_context"={
  22.  *              "groups"={
  23.  *                  "GameParams:output",
  24.  *                  "GameParams:io",
  25.  *              }
  26.  *          },
  27.  *          "denormalization_context"={
  28.  *              "groups"={
  29.  *                  "GameParams:input",
  30.  *                  "GameParams:io",
  31.  *              }
  32.  *          },
  33.  *         "order"={"startDate": "ASC"}
  34.  *      },
  35.  *     collectionOperations={
  36.  *          "public-get"={
  37.  *              "path"="/public/game_params",
  38.  *              "method"="GET",
  39.  *              "access_control"="is_granted('ROLE_PUBLIC')",
  40.  *          },
  41.  *          "get"={
  42.  *              "method"="GET",
  43.  *              "access_control"="is_granted('ROLE_USER')",
  44.  *          }
  45.  *     },
  46.  * )
  47.  *
  48.  */
  49. class GameParams extends WebsiteParams
  50. {
  51.     /**
  52.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  53.      * @Groups({
  54.      *     "WebsiteParams:output",
  55.      *     "GameParams:output",
  56.      * })
  57.      * @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
  58.      * @AppAssert\OverlappingDate(
  59.      *     class="App\Entity\WebsiteParams\GameParams",
  60.      *     startField="startDate",
  61.      *     endField="endDate",
  62.      *     customMsg="Une autre communication est déjà paramétrée dans cette tranche de date",
  63.      *     groups={
  64.      *     "GameParams",
  65.      * }
  66.      * )
  67.      */
  68.     private $startDate;
  69.     /**
  70.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  71.      * @Groups({
  72.      *     "WebsiteParams:output",
  73.      *     "GameParams:output",
  74.      * })
  75.      * @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
  76.      * @AppAssert\OverlappingDate(
  77.      *     class="App\Entity\WebsiteParams\GameParams",
  78.      *     startField="startDate",
  79.      *     endField="endDate",
  80.      *     customMsg="Une autre communication est déjà paramétrée dans cette tranche de date",
  81.      * )
  82.      */
  83.     private $endDate;
  84.     /**
  85.      * @ORM\Column(type="boolean", options={"default": 0})
  86.      * @Groups({
  87.      *     "WebsiteParams:output",
  88.      *     "GameParams:output",
  89.      * })
  90.      * @ApiFilter(BooleanFilter::class)
  91.      */
  92.     private bool $online false;
  93.     /**
  94.      * @ORM\Column(type="string", length=255, nullable=true)
  95.      * @Groups({
  96.      *     "WebsiteParams:output",
  97.      *     "GameParams:output",
  98.      * })
  99.      */
  100.     private ?string $title null;
  101.     /**
  102.      * @ORM\Column(type="string", length=255, nullable=true)
  103.      * @Groups({
  104.      *     "WebsiteParams:output",
  105.      *     "GameParams:output",
  106.      * })
  107.      */
  108.     private ?string $subtitle null;
  109.     /**
  110.      * @var MediaGameParams|null
  111.      * @ORM\OneToMany(targetEntity=MediaGameParams::class, mappedBy="gameParams", cascade={"persist"})
  112.      * @SerializedName("media_game_params")
  113.      * @Groups({
  114.      *     "WebsiteParams:output",
  115.      *     "GameParams:output",
  116.      *     "MediaGameParams:io"
  117.      * })
  118.      */
  119.     private $mediaGameParams;
  120.     public function __construct()
  121.     {
  122.         parent::__construct();
  123.         $this->mediaGameParams = new ArrayCollection();
  124.     }
  125.     public function getTitle(): ?string
  126.     {
  127.         return $this->title;
  128.     }
  129.     public function setTitle(?string $title): GameParams
  130.     {
  131.         $this->title $title;
  132.         return $this;
  133.     }
  134.     public function getSubtitle(): ?string
  135.     {
  136.         return $this->subtitle;
  137.     }
  138.     public function setSubtitle(?string $subtitle): GameParams
  139.     {
  140.         $this->subtitle $subtitle;
  141.         return $this;
  142.     }
  143.     public function getMediaGameParams()
  144.     {
  145.         return $this->mediaGameParams;
  146.     }
  147.     public function setMediaGameParams(MediaGameParams $mediaGameParams): GameParams
  148.     {
  149.         $this->mediaGameParams $mediaGameParams;
  150.         return $this;
  151.     }
  152.     public function getStartDate(): ?\DateTimeInterface
  153.     {
  154.         return $this->startDate;
  155.     }
  156.     public function setStartDate(\DateTimeInterface $startDate): self
  157.     {
  158.         $this->startDate $startDate;
  159.         return $this;
  160.     }
  161.     public function getEndDate(): ?\DateTimeInterface
  162.     {
  163.         return $this->endDate;
  164.     }
  165.     public function setEndDate(\DateTimeInterface $endDate): self
  166.     {
  167.         $this->endDate $endDate;
  168.         return $this;
  169.     }
  170.     public function isOnline(): bool
  171.     {
  172.         return (bool) $this->online;
  173.     }
  174.     public function getOnline(): bool
  175.     {
  176.         return (bool) $this->online;
  177.     }
  178.     public function setOnline(bool $online): self
  179.     {
  180.         $this->online $online;
  181.         return $this;
  182.     }
  183. }