src/Entity/Operation/Game.php line 68

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Operation;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\BooleanFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  7. use App\Entity\MediaObject\MediaGame;
  8. use App\Entity\MediaObject\MediaMobileGame;
  9. use App\Repository\Operation\GameRepository;
  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. /**
  16.  * @ORM\Entity(repositoryClass=GameRepository::class)
  17.  * @ApiResource(
  18.  *     attributes={
  19.  *          "normalization_context"={
  20.  *              "groups"={
  21.  *                  "OperationGame:output",
  22.  *                  "OperationGame:io"
  23.  *              }
  24.  *          },
  25.  *          "denormalization_context"={
  26.  *              "groups"={
  27.  *                  "OperationGame:input",
  28.  *                  "OperationGame:io"
  29.  *              }
  30.  *          },
  31.  *         "order"={"startDate": "ASC"}
  32.  *      },
  33.  *     collectionOperations={
  34.  *          "post"={
  35.  *              "method"="POST",
  36.  *              "access_control"="is_granted('ROLE_ADMIN_SOGEC')",
  37.  *          },
  38.  *          "public-get"={
  39.  *              "path"="/public/games",
  40.  *              "method"="GET",
  41.  *              "access_control"="is_granted('ROLE_PUBLIC')",
  42.  *          },
  43.  *          "get"={
  44.  *              "method"="GET",
  45.  *              "access_control"="is_granted('ROLE_USER')",
  46.  *          }
  47.  *     },
  48.  *     itemOperations={
  49.  *          "put"={
  50.  *              "method"="PUT",
  51.  *              "access_control"="is_granted('ROLE_ADMIN_SOGEC')",
  52.  *          },
  53.  *          "get"={
  54.  *              "method"="GET",
  55.  *              "access_control"="is_granted('ROLE_USER')",
  56.  *          },
  57.  *          "get-public"={
  58.  *              "method"="GET",
  59.  *              "path"="/public/game/{id}",
  60.  *          },
  61.  *      }
  62.  * )
  63.  *
  64.  */
  65. class Game extends Operation
  66. {
  67.     /**
  68.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  69.      * @Groups({
  70.      *     "OperationGame:io"
  71.      * })
  72.      * @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
  73.      */
  74.     private $startDate;
  75.     /**
  76.      * @ORM\Column(type="datetime", options={"default": "CURRENT_TIMESTAMP"})
  77.      * @Groups({
  78.      *     "OperationGame:io"
  79.      * })
  80.      * @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
  81.      */
  82.     private $endDate;
  83.     /**
  84.      * @ORM\Column(type="datetime", nullable=true)
  85.      * @Groups({
  86.      *     "OperationGame:io"
  87.      * })
  88.      * @ApiFilter(DateFilter::class, strategy=DateFilter::EXCLUDE_NULL)
  89.      */
  90.     private $openingDate;
  91.     /**
  92.      * @var MediaGame|null
  93.      * @ORM\OneToMany(targetEntity=MediaGame::class, mappedBy="game", cascade={"persist"})
  94.      * @SerializedName("media_games")
  95.      * @Groups({
  96.      *     "OperationGame:output",
  97.      *     "MediaGame:io"
  98.      * })
  99.      */
  100.     private $mediaGames;
  101.     /**
  102.      * @var MediaMobileGame|null
  103.      * @ORM\OneToMany(targetEntity=MediaMobileGame::class, mappedBy="game", cascade={"persist"})
  104.      * @SerializedName("mobile_games")
  105.      * @Groups({
  106.      *     "OperationGame:output",
  107.      *     "MediaMobileGame:io",
  108.      * })
  109.      */
  110.     private $mobileGames;
  111.     /**
  112.      * @ORM\Column(type="boolean", options={"default": 0})
  113.      * @Groups({
  114.      *     "OperationGame:io"
  115.      * })
  116.      * @ApiFilter(BooleanFilter::class)
  117.      */
  118.     private bool $online false;
  119.     /**
  120.      * @ORM\Column(type="boolean", options={"default": 0})
  121.      * @Groups({
  122.      *     "OperationGame:io",
  123.      * })
  124.      * @ApiFilter(BooleanFilter::class)
  125.      */
  126.     private bool $requireUser false;
  127.     /**
  128.      * @ORM\Column(type="string", length=255, nullable=true)
  129.      * @Groups({
  130.      *     "OperationGame:io",
  131.      * })
  132.      */
  133.     private string $url;
  134.     /**
  135.      * @ORM\Column(type="string", length=255, nullable=true)
  136.      * @Groups({
  137.      *     "OperationGame:io",
  138.      * })
  139.      */
  140.     private ?string $extend;
  141.     /**
  142.      * @ORM\Column(type="integer", options={"default": 1})
  143.      */
  144.     private $maxPartByUser 1;
  145.     /**
  146.      * @ORM\Column(type="string", length=255, nullable=true)
  147.      * @Groups({
  148.      *     "OperationGame:io",
  149.      * })
  150.      */
  151.     private ?string $description;
  152.     public function __construct()
  153.     {
  154.         parent::__construct();
  155.         $this->mediaGames = new ArrayCollection();
  156.         $this->mobileGames = new ArrayCollection();
  157.     }
  158.     public function getOpeningDate(): ?\DateTimeInterface
  159.     {
  160.         return $this->openingDate;
  161.     }
  162.     public function setOpeningDate(?\DateTimeInterface $openingDate): self
  163.     {
  164.         $this->openingDate $openingDate;
  165.         return $this;
  166.     }
  167.     public function getStartDate(): ?\DateTimeInterface
  168.     {
  169.         return $this->startDate;
  170.     }
  171.     public function setStartDate(\DateTimeInterface $startDate): self
  172.     {
  173.         $this->startDate $startDate;
  174.         return $this;
  175.     }
  176.     public function getEndDate(): ?\DateTimeInterface
  177.     {
  178.         return $this->endDate;
  179.     }
  180.     public function setEndDate(\DateTimeInterface $endDate): self
  181.     {
  182.         $this->endDate $endDate;
  183.         return $this;
  184.     }
  185.     public function isOnline(): bool
  186.     {
  187.         return (bool) $this->online;
  188.     }
  189.     public function getOnline(): bool
  190.     {
  191.         return (bool) $this->online;
  192.     }
  193.     public function setOnline(bool $online): self
  194.     {
  195.         $this->online $online;
  196.         return $this;
  197.     }
  198.     public function isRequireUser(): bool
  199.     {
  200.         return (bool) $this->requireUser;
  201.     }
  202.     public function getRequireUser(): bool
  203.     {
  204.         return (bool) $this->requireUser;
  205.     }
  206.     public function setRequireUser(bool $requireUser): self
  207.     {
  208.         $this->requireUser $requireUser;
  209.         return $this;
  210.     }
  211.     public function getUrl(): ?string
  212.     {
  213.         return $this->url;
  214.     }
  215.     public function setUrl(string $url): Game
  216.     {
  217.         $this->url $url;
  218.         return $this;
  219.     }
  220.     public function getExtend(): ?string
  221.     {
  222.         return $this->extend;
  223.     }
  224.     public function setExtend(?string $extend): Game
  225.     {
  226.         $this->extend $extend;
  227.         return $this;
  228.     }
  229.     public function getMaxPartByUser(): ?int
  230.     {
  231.         return $this->maxPartByUser;
  232.     }
  233.     public function setMaxPartByUser(int $maxPartByUser): self
  234.     {
  235.         $this->maxPartByUser $maxPartByUser;
  236.         return $this;
  237.     }
  238.     public function getMediaGames()
  239.     {
  240.         return $this->mediaGames;
  241.     }
  242.     public function setMediaGame(MediaGame $mediaGames): Game
  243.     {
  244.         $this->mediaGames $mediaGames;
  245.         return $this;
  246.     }
  247.     public function addMediaGame(MediaGame $mediaGame)
  248.     {
  249.         if ($this->mediaGames->contains($mediaGame)) {
  250.             return;
  251.         }
  252.         $this->mediaGames[] = $mediaGame;
  253.         $mediaGame->setGame($this);
  254.     }
  255.     public function getMobileGames()
  256.     {
  257.         return $this->mobileGames;
  258.     }
  259.     public function setMobileGame(MediaMobileGame $mobileGames): Game
  260.     {
  261.         $this->mobileGames $mobileGames;
  262.         return $this;
  263.     }
  264.     public function addMobileGame(MediaMobileGame $mobileGame)
  265.     {
  266.         if ($this->mobileGames->contains($mobileGame)) {
  267.             return;
  268.         }
  269.         $this->mobileGames[] = $mobileGame;
  270.         $mobileGame->setGame($this);
  271.     }
  272.     /**
  273.      * @return string
  274.      */
  275.     public function getDescription(): ?string
  276.     {
  277.         return $this->description;
  278.     }
  279.     public function setDescription(?string $description): self
  280.     {
  281.         $this->description $description;
  282.         return $this;
  283.     }
  284. }