<?php
namespace App\Entity;
use App\Entity\Server\ManageIt\DataCenter;
use App\Entity\VPN\V2ray\Protocol;
use App\Entity\VPN\V2ray\Server;
use App\Repository\CountryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JetBrains\PhpStorm\Pure;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
#[ORM\Entity(repositoryClass: CountryRepository::class)]
class Country extends BaseEntity
{
#[ORM\Id]
#[ORM\Column(type: 'guid', unique: true)]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\CustomIdGenerator(class: UuidGenerator::class)]
private ?string $id = null;
#[ORM\Column(length: 255)]
private ?string $title = null;
#[ORM\Column(length: 255)]
private ?string $code = null;
#[ORM\Column(length: 255)]
private ?string $flag = null;
#[ORM\OneToMany(mappedBy: 'country', targetEntity: Server::class)]
private Collection $v2rayServers;
#[ORM\OneToMany(mappedBy: 'country', targetEntity: \App\Entity\VPN\OpenVPN\Server::class)]
private Collection $OpenVPNServers;
#[ORM\OneToMany(mappedBy: 'country', targetEntity: \App\Entity\VPN\OcServ\Server::class)]
private Collection $servers;
#[ORM\OneToMany(mappedBy: 'country', targetEntity: Protocol::class)]
private Collection $protocols;
#[ORM\OneToMany(mappedBy: 'location', targetEntity: DataCenter::class)]
private Collection $manageItDataCenters;
public function __construct()
{
parent::__construct();
$this->protocols = new ArrayCollection();
$this->manageItDataCenters = new ArrayCollection();
}
#[Pure] public function __toString()
{
return ($this->getTitle());
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getId(): ?string
{
return $this->id;
}
public function getFlag(): ?string
{
return $this->flag;
}
public function setFlag(string $flag): self
{
$this->flag = $flag;
return $this;
}
/**
* @return Collection<int, Protocol>
*/
public function getProtocols(): Collection
{
return $this->protocols;
}
public function addProtocol(Protocol $protocol): static
{
if (!$this->protocols->contains($protocol)) {
$this->protocols->add($protocol);
$protocol->setCountry($this);
}
return $this;
}
public function removeProtocol(Protocol $protocol): static
{
if ($this->protocols->removeElement($protocol)) {
// set the owning side to null (unless already changed)
if ($protocol->getCountry() === $this) {
$protocol->setCountry(null);
}
}
return $this;
}
/**
* @return Collection<int, DataCenter>
*/
public function getManageItDataCenters(): Collection
{
return $this->manageItDataCenters;
}
public function addManageItDataCenter(DataCenter $manageItDataCenter): static
{
if (!$this->manageItDataCenters->contains($manageItDataCenter)) {
$this->manageItDataCenters->add($manageItDataCenter);
$manageItDataCenter->setLocation($this);
}
return $this;
}
public function removeManageItDataCenter(DataCenter $manageItDataCenter): static
{
if ($this->manageItDataCenters->removeElement($manageItDataCenter)) {
// set the owning side to null (unless already changed)
if ($manageItDataCenter->getLocation() === $this) {
$manageItDataCenter->setLocation(null);
}
}
return $this;
}
}