<?php
namespace App\Entity\VPN\OcServ;
use App\Entity\BaseEntity;
use App\Entity\Country;
use App\Repository\VPN\OcServ\ServerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
#[ORM\Table(name: '`ocserv_server`')]
#[ORM\Entity(repositoryClass: ServerRepository::class)]
class Server 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 $ip = null;
#[ORM\Column(length: 255)]
private ?string $sshUsername = null;
#[ORM\Column(length: 255)]
private ?string $sshPassword = null;
#[ORM\Column]
private ?int $servicePort = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\ManyToOne(inversedBy: 'servers')]
#[ORM\JoinColumn(nullable: false)]
private ?Country $country = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $passwdContent = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $note = null;
#[ORM\Column(nullable: true)]
private ?int $totalServicesCount = null;
/**
* @var Collection<int, Protocol>
*/
#[ORM\OneToMany(targetEntity: Protocol::class, mappedBy: 'server')]
private Collection $protocols;
public function __construct()
{
parent::__construct();
$this->protocols = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getIp(): ?string
{
return $this->ip;
}
public function setIp(string $ip): static
{
$this->ip = $ip;
return $this;
}
public function getSshUsername(): ?string
{
return $this->sshUsername;
}
public function setSshUsername(string $sshUsername): static
{
$this->sshUsername = $sshUsername;
return $this;
}
public function getSshPassword(): ?string
{
return $this->sshPassword;
}
public function setSshPassword(string $sshPassword): static
{
$this->sshPassword = $sshPassword;
return $this;
}
public function getServicePort(): ?int
{
return $this->servicePort;
}
public function setServicePort(int $servicePort): static
{
$this->servicePort = $servicePort;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): static
{
$this->country = $country;
return $this;
}
public function getPasswdContent(): ?string
{
return $this->passwdContent;
}
public function setPasswdContent(?string $passwdContent): static
{
$this->passwdContent = $passwdContent;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): static
{
$this->note = $note;
return $this;
}
public function getTotalServicesCount(): ?int
{
return $this->totalServicesCount;
}
public function setTotalServicesCount(?int $totalServicesCount): static
{
$this->totalServicesCount = $totalServicesCount;
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->setServer($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->getServer() === $this) {
$protocol->setServer(null);
}
}
return $this;
}
}