<?php
namespace App\Entity\Server\Hetzner;
use App\Entity\BaseEntity;
use App\Repository\Server\Hetzner\ImageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
#[ORM\Entity(repositoryClass: ImageRepository::class)]
#[ORM\Table(name: '`hetzner_sell_server_image`')]
class Image extends BaseEntity
{
#[ORM\Id]
#[ORM\Column(type: 'guid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private $id;
#[ORM\Column(length: 255, nullable: true)]
private ?string $architecture = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $systemId = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $status = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $description = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image_size = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $disk_size = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $os_flavor = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $os_version = null;
#[ORM\OneToMany(mappedBy: 'image', targetEntity: Server::class)]
private Collection $servers;
public function __construct()
{
parent::__construct();
$this->servers = new ArrayCollection();
}
public function __toString()
{
return $this->getOsFlavor().' - '.$this->getOsVersion();
}
public function getId(): ?string
{
return $this->id;
}
public function getArchitecture(): ?string
{
return $this->architecture;
}
public function setArchitecture(?string $architecture): static
{
$this->architecture = $architecture;
return $this;
}
public function getSystemId(): ?string
{
return $this->systemId;
}
public function setSystemId(?string $systemId): static
{
$this->systemId = $systemId;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): static
{
$this->status = $status;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): static
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getImageSize(): ?string
{
return $this->image_size;
}
public function setImageSize(?string $image_size): static
{
$this->image_size = $image_size;
return $this;
}
public function getDiskSize(): ?string
{
return $this->disk_size;
}
public function setDiskSize(?string $disk_size): static
{
$this->disk_size = $disk_size;
return $this;
}
public function getOsFlavor(): ?string
{
return $this->os_flavor;
}
public function setOsFlavor(?string $os_flavor): static
{
$this->os_flavor = $os_flavor;
return $this;
}
public function getOsVersion(): ?string
{
return $this->os_version;
}
public function setOsVersion(?string $os_version): static
{
$this->os_version = $os_version;
return $this;
}
/**
* @return Collection<int, Server>
*/
public function getServers(): Collection
{
return $this->servers;
}
public function addServer(Server $server): static
{
if (!$this->servers->contains($server)) {
$this->servers->add($server);
$server->setImage($this);
}
return $this;
}
public function removeServer(Server $server): static
{
if ($this->servers->removeElement($server)) {
// set the owning side to null (unless already changed)
if ($server->getImage() === $this) {
$server->setImage(null);
}
}
return $this;
}
}