<?php
namespace App\Entity;
use App\Annotation\EsUploadable;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\BackgroundRepository;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\Interfaces\UploadMappedInterface;
use App\Entity\Interfaces\ContainerMappedInterface;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
/**
* @ApiResource(
* attributes={"security"="is_granted('ROLE_OPERATOR')"},
* normalizationContext={"groups"={"Background:Read"}, "skip_null_values"=false},
* denormalizationContext={"groups"={"Background:Write"}},
* collectionOperations={
* "get"={
* "security"="is_granted('IS_AUTHENTICATED_FULLY')",
* "pagination_enabled"=false
* },
* "post"
* },
* itemOperations={
* "get"={"security"="is_granted('IS_AUTHENTICATED_FULLY', object)"},
* "put"={"security"="is_granted('IS_CO_OPR', object)"},
* "patch"={"security"="is_granted('IS_CO_OPR', object)"},
* "delete"={"security"="is_granted('IS_CO_OPR', object)"}
* }
* )
* @ApiFilter(SearchFilter::class, properties={"id": "exact", "container.id": "exact"})
* @ORM\Entity(repositoryClass=BackgroundRepository::class)
*/
class Background implements ContainerMappedInterface, UploadMappedInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({"Background:Read", "Container:MyContainer"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"Background:Read", "Background:Write", "Container:MyContainer"})
* @EsUploadable()
*/
protected $imageName;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"Background:Read", "Background:Write", "Container:MyContainer"})
* @EsUploadable()
*/
private $mobileImageName;
/**
* @ORM\Column(type="string", length=16, nullable=true)
* @Groups({"Background:Read", "Background:Write", "Container:MyContainer"})
*/
private $color;
/**
* @ORM\Column(type="array", nullable=true)
* @Groups({"Background:Read", "Background:Write", "Container:MyContainer"})
*/
private $urls = [];
/**
* @ORM\ManyToOne(targetEntity=Container::class, inversedBy="backgrounds")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
* @Groups({"Background:Write"})
*/
private $container;
public function getId(): ?int
{
return $this->id;
}
public function getImageName(): ?string
{
return $this->imageName;
}
public function setImageName(?string $imageName): self
{
$this->imageName = $imageName;
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(?string $color): self
{
$this->color = $color;
return $this;
}
public function getUrls(): ?array
{
return $this->urls;
}
public function setUrls(?array $urls): self
{
$this->urls = $urls;
return $this;
}
public function getContainer(): ?Container
{
return $this->container;
}
public function setContainer(?Container $container): self
{
$this->container = $container;
return $this;
}
public function getMobileImageName(): ?string
{
return $this->mobileImageName;
}
public function setMobileImageName(?string $mobileImageName): self
{
$this->mobileImageName = $mobileImageName;
return $this;
}
}