<?php
namespace App\Entity\Server\ManageIt;
use App\Entity\BaseEntity;
use App\Entity\Country;
use App\Repository\Server\ManageIt\DataCenterRepository;
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\Entity(repositoryClass: DataCenterRepository::class)]
#[ORM\Table(name: '`manageit_sell_server_datacenter`')]
class DataCenter 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)]
private ?string $systemId = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $description = null;
#[ORM\ManyToOne(inversedBy: 'manageItDataCenters')]
#[ORM\JoinColumn(nullable: false)]
private ?Country $location = null;
#[ORM\Column(type: Types::BIGINT)]
private ?string $trafficPrice = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\OneToMany(mappedBy: 'datacenter', targetEntity: ServerType::class)]
private Collection $serverTypes;
public function __toString()
{
return $this->getLocation().' - '.'tehrannet' .' - '. $this->getName();
}
public function __construct()
{
parent::__construct();
$this->serverTypes = new ArrayCollection();
}
public function getId(): ?string
{
return $this->id;
}
public function getSystemId(): ?string
{
return $this->systemId;
}
public function setSystemId(string $systemId): static
{
$this->systemId = $systemId;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getLocation(): ?Country
{
return $this->location;
}
public function setLocation(?Country $location): static
{
$this->location = $location;
return $this;
}
public function getTrafficPrice(): ?string
{
return $this->trafficPrice;
}
public function setTrafficPrice(string $trafficPrice): static
{
$this->trafficPrice = $trafficPrice;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, ServerType>
*/
public function getServerTypes(): Collection
{
return $this->serverTypes;
}
public function addServerType(ServerType $serverType): static
{
if (!$this->serverTypes->contains($serverType)) {
$this->serverTypes->add($serverType);
$serverType->setDatacenter($this);
}
return $this;
}
public function removeServerType(ServerType $serverType): static
{
if ($this->serverTypes->removeElement($serverType)) {
// set the owning side to null (unless already changed)
if ($serverType->getDatacenter() === $this) {
$serverType->setDatacenter(null);
}
}
return $this;
}
}