src/Entity/Coleccion.php line 22
<?phpnamespace App\Entity;use App\Entity\ApiToken;use App\Repository\ColeccionRepository;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use Symfony\Component\Serializer\Annotation\Groups;use ApiPlatform\Metadata\ApiFilter;use ApiPlatform\Doctrine\Orm\Filter\DateFilter;use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;use Symfony\Component\Validator\Constraints as Assert;#[ORM\Entity(repositoryClass: ColeccionRepository::class)]#[ApiResource(description: 'Colecciones de Herdasa',shortName: 'colecciones',//Fichero para ver posibles opciones vendor/api-platform/core/src/Metadata/ApiResource.phpoperations:[new Get(security: 'is_granted("' . ApiToken::SCOPE_USER_READ . '")'),new GetCollection(security: 'is_granted("' . ApiToken::SCOPE_USER_READ . '")'),],normalizationContext:['groups' => ['colecciones:read']])]#[ORM\Index(name: "coleccion_idx", columns: ["id"])]#[ORM\Index(name: "coleccion_in_modelos_idx", columns: ["id", "nombre"])]#[ORM\Index(name: "idx_coleccion_nombre", columns: ["nombre"])]#[ORM\Index(name: "idx_coleccion_descripcion", columns: ["descripcion"], options: ["lengths" => [255]])]#[ApiFilter(DateFilter::class, properties: ['updatedAt'])]class Coleccion{#[ORM\Id, ORM\Column]#[ApiFilter(SearchFilter::class, strategy: "exact")]#[Groups(['programa:read', 'colecciones:read', 'modelo:read', 'composicion:read'])]#[Assert\NotBlank(message: "El id es requerido.")]private ?string $id = null;#[ORM\Column(length: 255)]#[Groups(['programa:read', 'colecciones:read', 'modelo:read', 'composicion:read'])]#[Assert\NotBlank(message: "El nombre es requerido.")]private ?string $nombre = null;#[ORM\Column(type: Types::TEXT, nullable: true)]#[Groups([ 'colecciones:read', 'modelo:read'])]private ?string $descripcion = null;#[ORM\Column]private ?\DateTimeImmutable $createdAt = null;#[ORM\Column]private ?\DateTimeImmutable $updatedAt = null;#[ORM\ManyToOne(targetEntity:Programa::class, inversedBy: 'colecciones')]#[Groups([ 'colecciones:read', 'modelo:read', 'composicion:read'])]private ?Programa $programa = null;#[ORM\ManyToOne(targetEntity: Imagen::class)]#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]#[Groups(['colecciones:read', 'programa:read'])]private ?Imagen $imagen_primaria = null;#[ORM\ManyToOne(targetEntity: Imagen::class)]#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]#[Groups(['colecciones:read'])]private ?Imagen $imagen_secundaria = null;#[ORM\ManyToOne(targetEntity: Imagen::class)]#[ORM\JoinColumn(nullable: true, onDelete: "SET NULL")]#[Groups(['colecciones:read', 'modelo:read'])]private ?Imagen $icono = null;#[ORM\ManyToMany(targetEntity: Imagen::class)]#[ORM\JoinTable(name: "coleccion_repositorio_imagenes")]private Collection $repositorio_imagenes;#[ORM\ManyToMany(targetEntity: Imagen::class)]#[ORM\JoinTable(name: "coleccion_imagenes_web")]#[Groups(['colecciones:read'])]private Collection $imagenes_web;#[ORM\OneToMany(mappedBy: 'coleccion', targetEntity: Modelo::class)]#[Groups(['colecciones:read'])]private Collection $modelos;public function __construct(){$this->modelos = new ArrayCollection();$this->repositorio_imagenes = new ArrayCollection();$this->imagenes_web = new ArrayCollection();}public function __toString(){return $this->nombre; //or anything else}public function getId(): ?string{return $this->id;}public function setId(?string $id): self{$this->id = $id;return $this;}public function getNombre(): ?string{return $this->nombre;}public function setNombre(string $nombre): self{$this->nombre = $nombre;return $this;}public function getDescripcion(): ?string{return $this->descripcion;}public function setDescripcion(?string $descripcion): self{$this->descripcion = $descripcion;return $this;}public function getCreatedAt(): ?\DateTimeImmutable{return $this->createdAt;}public function setCreatedAt(\DateTimeImmutable $createdAt): self{$this->createdAt = $createdAt;return $this;}public function getUpdatedAt(): ?\DateTimeImmutable{return $this->updatedAt;}public function setUpdatedAt(\DateTimeImmutable $updatedAt): self{$this->updatedAt = $updatedAt;return $this;}public function getPrograma(): ?Programa{return $this->programa;}public function setPrograma(?Programa $programa): static{$this->programa = $programa;return $this;}/*** @return Collection<int, Modelo>*/public function getModelos(): Collection{return $this->modelos;}public function addModelo(Modelo $modelo): static{if (!$this->modelos->contains($modelo)) {$this->modelos->add($modelo);$modelo->setColeccion($this);}return $this;}public function removeModelo(Modelo $modelo): static{if ($this->modelos->removeElement($modelo)) {// set the owning side to null (unless already changed)if ($modelo->getColeccion() === $this) {$modelo->setColeccion(null);}}return $this;}#[Groups('colecciones:read')]public function getModificado(): ?\DateTimeImmutable{return $this->updatedAt;}public function getImagenPrimaria(): ?Imagen{return $this->imagen_primaria;}public function setImagenPrimaria(?Imagen $imagen_primaria): static{$this->imagen_primaria = $imagen_primaria;return $this;}public function getImagenSecundaria(): ?Imagen{return $this->imagen_secundaria;}public function setImagenSecundaria(?Imagen $imagen_secundaria): static{$this->imagen_secundaria = $imagen_secundaria;return $this;}public function setIcono(?Imagen $icono): static{$this->icono = $icono;return $this;}public function getIcono(): ?Imagen{return $this->icono;}/*** @return Collection<int, Imagen>*/public function getRepositorioImagenes(): Collection{return $this->repositorio_imagenes;}public function addRepositorioImagenes(Imagen $repositorioImagene): static{if (!$this->repositorio_imagenes->contains($repositorioImagene)) {$this->repositorio_imagenes->add($repositorioImagene);}return $this;}public function removeRepositorioImagenes(Imagen $repositorioImagenes): static{$this->repositorio_imagenes->removeElement($repositorioImagenes);return $this;}/*** @return Collection<int, Imagen>*/public function getImagenesWeb(): Collection{return $this->imagenes_web;}public function addImagenesWeb(Imagen $imagenesWeb): static{if (!$this->imagenes_web->contains($imagenesWeb)) {$this->imagenes_web->add($imagenesWeb);}return $this;}public function removeImagenesWeb(Imagen $imagenesWeb): static{$this->imagenes_web->removeElement($imagenesWeb);return $this;}public function getRepositorio_imagenes(): ?array{return $this->getRepositorioImagenes();}public function setRepositorio_imagenes(?array $repositorio_imagenes): self{return $this->setRepositorioImagenes($repositorio_imagenes);}public function removeImageRepositorio_imagenes($imageName): self{if ($key = array_search($imageName, $this->repositorio_imagenes)) {unset($this->repositorio_imagenes[$key]);}return $this;}public function getImagen_primaria(): ?string{return $this->getImagenPrimaria();}public function getImagen_secundaria(): ?string{return $this->getImagenSecundaria();}public function getImagenes_web(): ?array{return $this->getImagenesWeb();}public function setImagenes_web(?array $imagenes_web): self{return $this->setImagenesWeb($imagenes_web);}// #[ApiProperty(readable: true, serialized_name: 'imagen_primaria')]// #[Groups(['colecciones:read'])]// public function getImagenPrimariaRute(): ?string// {// return $this->imagen_primaria ? $this->imagen_primaria->getRute() : null;// }// #[ApiProperty(readable: true, serialized_name: 'imagen_secundaria')]// #[Groups(['colecciones:read'])]// public function getImagenSecundariaRute(): ?string// {// return $this->imagen_secundaria ? $this->imagen_secundaria->getRute() : null;// }// #[ApiProperty(readable: true, serialized_name: 'imagenes_web')]// #[Groups(['colecciones:read'])]// public function getImagenesWebRutes(): array// {// return $this->imagenes_web->map(function (Imagen $imagen) {// return $imagen->getRute();// })->toArray();// }// #[ApiProperty(readable: true, serialized_name: 'icono')]// #[Groups(['colecciones:read'])]// public function getIconoRoute(): array// {// return $this->icono ? $this->icono->getRute() : null;// }}