src/Entity/Server/Hetzner/DataCenter.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Server\Hetzner;
  3. use App\Entity\BaseEntity;
  4. use App\Repository\Server\Hetzner\DataCenterRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  9. #[ORM\Entity(repositoryClassDataCenterRepository::class)]
  10. #[ORM\Table(name'`hetzner_sell_server_datacenter`')]
  11. class DataCenter extends BaseEntity
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\Column(type'guid'uniquetrue)]
  15.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  16.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  17.     private $id;
  18.     #[ORM\Column(length255nullabletrue)]
  19.     private ?string $systemId null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $description null;
  22.     #[ORM\ManyToOne(inversedBy'dataCenters')]
  23.     #[ORM\JoinColumn(nullablefalse)]
  24.     private ?Location $location null;
  25.     #[ORM\OneToMany(mappedBy'datacenter'targetEntityDataCenterSupportedServerTypes::class)]
  26.     private Collection $dataCenterSupportedServerTypes;
  27.     #[ORM\OneToMany(mappedBy'datacenter'targetEntityServer::class)]
  28.     private Collection $servers;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $name null;
  31.     public function __construct()
  32.     {
  33.         parent::__construct();
  34.         $this->dataCenterSupportedServerTypes = new ArrayCollection();
  35.         $this->servers = new ArrayCollection();
  36.     }
  37.     public function __toString()
  38.     {
  39.         return $this->getLocation()->getCountry().' - '.$this->getLocation()->getCity() .' - '.  $this->getName();
  40.     }
  41.     public function getId(): ?string
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getSystemId(): ?string
  46.     {
  47.         return $this->systemId;
  48.     }
  49.     public function setSystemId(?string $systemId): static
  50.     {
  51.         $this->systemId $systemId;
  52.         return $this;
  53.     }
  54.     public function getDescription(): ?string
  55.     {
  56.         return $this->description;
  57.     }
  58.     public function setDescription(?string $description): static
  59.     {
  60.         $this->description $description;
  61.         return $this;
  62.     }
  63.     public function getLocation(): ?Location
  64.     {
  65.         return $this->location;
  66.     }
  67.     public function setLocation(?Location $location): static
  68.     {
  69.         $this->location $location;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection<int, DataCenterSupportedServerTypes>
  74.      */
  75.     public function getDataCenterSupportedServerTypes(): Collection
  76.     {
  77.         return $this->dataCenterSupportedServerTypes;
  78.     }
  79.     public function addDataCenterSupportedServerType(DataCenterSupportedServerTypes $dataCenterSupportedServerType): static
  80.     {
  81.         if (!$this->dataCenterSupportedServerTypes->contains($dataCenterSupportedServerType)) {
  82.             $this->dataCenterSupportedServerTypes->add($dataCenterSupportedServerType);
  83.             $dataCenterSupportedServerType->setDatacenter($this);
  84.         }
  85.         return $this;
  86.     }
  87.     public function removeDataCenterSupportedServerType(DataCenterSupportedServerTypes $dataCenterSupportedServerType): static
  88.     {
  89.         if ($this->dataCenterSupportedServerTypes->removeElement($dataCenterSupportedServerType)) {
  90.             // set the owning side to null (unless already changed)
  91.             if ($dataCenterSupportedServerType->getDatacenter() === $this) {
  92.                 $dataCenterSupportedServerType->setDatacenter(null);
  93.             }
  94.         }
  95.         return $this;
  96.     }
  97.     /**
  98.      * @return Collection<int, Server>
  99.      */
  100.     public function getServers(): Collection
  101.     {
  102.         return $this->servers;
  103.     }
  104.     public function addServer(Server $server): static
  105.     {
  106.         if (!$this->servers->contains($server)) {
  107.             $this->servers->add($server);
  108.             $server->setDatacenter($this);
  109.         }
  110.         return $this;
  111.     }
  112.     public function removeServer(Server $server): static
  113.     {
  114.         if ($this->servers->removeElement($server)) {
  115.             // set the owning side to null (unless already changed)
  116.             if ($server->getDatacenter() === $this) {
  117.                 $server->setDatacenter(null);
  118.             }
  119.         }
  120.         return $this;
  121.     }
  122.     public function getName(): ?string
  123.     {
  124.         return $this->name;
  125.     }
  126.     public function setName(?string $name): static
  127.     {
  128.         $this->name $name;
  129.         return $this;
  130.     }
  131. }