src/Entity/Background.php line 37

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Annotation\EsUploadable;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Repository\BackgroundRepository;
  6. use ApiPlatform\Core\Annotation\ApiFilter;
  7. use ApiPlatform\Core\Annotation\ApiResource;
  8. use App\Entity\Interfaces\UploadMappedInterface;
  9. use App\Entity\Interfaces\ContainerMappedInterface;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  12. /**
  13.  * @ApiResource(
  14.  *      attributes={"security"="is_granted('ROLE_OPERATOR')"},
  15.  *      normalizationContext={"groups"={"Background:Read"}, "skip_null_values"=false},
  16.  *      denormalizationContext={"groups"={"Background:Write"}},
  17.  *      collectionOperations={
  18.  *          "get"={
  19.  *              "security"="is_granted('IS_AUTHENTICATED_FULLY')",
  20.  *              "pagination_enabled"=false
  21.  *          },
  22.  *          "post"
  23.  *      },
  24.  *      itemOperations={
  25.  *          "get"={"security"="is_granted('IS_AUTHENTICATED_FULLY', object)"},
  26.  *          "put"={"security"="is_granted('IS_CO_OPR', object)"},
  27.  *          "patch"={"security"="is_granted('IS_CO_OPR', object)"},
  28.  *          "delete"={"security"="is_granted('IS_CO_OPR', object)"}
  29.  *     }
  30.  * )
  31.  * @ApiFilter(SearchFilter::class, properties={"id": "exact", "container.id": "exact"})
  32.  * @ORM\Entity(repositoryClass=BackgroundRepository::class)
  33.  */
  34. class Background implements ContainerMappedInterfaceUploadMappedInterface
  35. {
  36.     /**
  37.      * @ORM\Id
  38.      * @ORM\GeneratedValue
  39.      * @ORM\Column(type="integer")
  40.      * @Groups({"Background:Read", "Container:MyContainer"})
  41.      */
  42.     private $id;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      * @Groups({"Background:Read", "Background:Write", "Container:MyContainer"})
  46.      * @EsUploadable()
  47.      */
  48.     protected $imageName;
  49.     /**
  50.      * @ORM\Column(type="string", length=255, nullable=true)
  51.      * @Groups({"Background:Read", "Background:Write", "Container:MyContainer"})
  52.      * @EsUploadable()
  53.      */
  54.     private $mobileImageName;
  55.     /**
  56.      * @ORM\Column(type="string", length=16, nullable=true)
  57.      * @Groups({"Background:Read", "Background:Write", "Container:MyContainer"})
  58.      */
  59.     private $color;
  60.     /**
  61.      * @ORM\Column(type="array", nullable=true)
  62.      * @Groups({"Background:Read", "Background:Write", "Container:MyContainer"})
  63.      */
  64.     private $urls = [];
  65.     /**
  66.      * @ORM\ManyToOne(targetEntity=Container::class, inversedBy="backgrounds")
  67.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  68.      * @Groups({"Background:Write"})
  69.      */
  70.     private $container;
  71.     public function getId(): ?int
  72.     {
  73.         return $this->id;
  74.     }
  75.     public function getImageName(): ?string
  76.     {
  77.         return $this->imageName;
  78.     }
  79.     public function setImageName(?string $imageName): self
  80.     {
  81.         $this->imageName $imageName;
  82.         return $this;
  83.     }
  84.     public function getColor(): ?string
  85.     {
  86.         return $this->color;
  87.     }
  88.     public function setColor(?string $color): self
  89.     {
  90.         $this->color $color;
  91.         return $this;
  92.     }
  93.     public function getUrls(): ?array
  94.     {
  95.         return $this->urls;
  96.     }
  97.     public function setUrls(?array $urls): self
  98.     {
  99.         $this->urls $urls;
  100.         return $this;
  101.     }
  102.     public function getContainer(): ?Container
  103.     {
  104.         return $this->container;
  105.     }
  106.     public function setContainer(?Container $container): self
  107.     {
  108.         $this->container $container;
  109.         return $this;
  110.     }
  111.     public function getMobileImageName(): ?string
  112.     {
  113.         return $this->mobileImageName;
  114.     }
  115.     public function setMobileImageName(?string $mobileImageName): self
  116.     {
  117.         $this->mobileImageName $mobileImageName;
  118.         return $this;
  119.     }
  120. }