src/Entity/Server/Hetzner/Server.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Server\Hetzner;
  3. use App\Entity\BaseEntity;
  4. use App\Entity\Generic\User;
  5. use App\Repository\Server\Hetzner\ServerRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  11. #[ORM\Entity(repositoryClassServerRepository::class)]
  12. #[ORM\Table(name'`hetzner_sell_server_server`')]
  13. class Server extends BaseEntity
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\Column(type'guid'uniquetrue)]
  17.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  18.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  19.     private $id;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $systemId null;
  22.     #[ORM\Column(length255nullabletrue)]
  23.     private ?string $name null;
  24.     #[ORM\Column(length255nullabletrue)]
  25.     private ?string $status null;
  26.     #[ORM\Column(typeTypes::BIGINTnullabletrue)]
  27.     private ?string $outgoingTraffic null;
  28.     #[ORM\Column(typeTypes::BIGINTnullabletrue)]
  29.     private ?string $ingoingTraffic null;
  30.     #[ORM\Column(typeTypes::BIGINTnullabletrue)]
  31.     private ?string $includedTraffic null;
  32.     #[ORM\OneToMany(mappedBy'server'targetEntityIp::class)]
  33.     private Collection $ips;
  34.     #[ORM\ManyToOne(inversedBy'hetznerServers')]
  35.     #[ORM\JoinColumn(nullablefalse)]
  36.     private ?User $owner null;
  37.     #[ORM\ManyToOne(inversedBy'servers')]
  38.     #[ORM\JoinColumn(nullablefalse)]
  39.     private ?ServerType $serverType null;
  40.     #[ORM\ManyToOne(inversedBy'servers')]
  41.     #[ORM\JoinColumn(nullablefalse)]
  42.     private ?DataCenter $datacenter null;
  43.     #[ORM\ManyToOne(inversedBy'servers')]
  44.     #[ORM\JoinColumn(nullablefalse)]
  45.     private ?Image $image null;
  46.     #[ORM\Column(length255)]
  47.     private ?string $rootPassword null;
  48.     #[ORM\Column]
  49.     private ?bool $rescueEnabled null;
  50.     #[ORM\Column(length255nullabletrue)]
  51.     private ?string $payMethod null;
  52.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  53.     private ?\DateTimeInterface $paidUntil null;
  54.     #[ORM\Column(nullabletrue)]
  55.     private ?bool $isPowerOn null;
  56.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  57.     private ?\DateTimeInterface $lastRebuild null;
  58.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  59.     private ?string $analytics null;
  60.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  61.     private ?string $actions null;
  62.     #[ORM\Column]
  63.     private ?bool $isSuspended null;
  64.     #[ORM\Column(length255nullabletrue)]
  65.     private ?string $suspendType null;
  66.     public function __construct()
  67.     {
  68.         parent::__construct();
  69.         $this->setIsSuspended(false);
  70.         $this->ips = new ArrayCollection();
  71.     }
  72.     public function getId(): ?string
  73.     {
  74.         return $this->id;
  75.     }
  76.     public function getNiceIps()
  77.     {
  78.         $string '';
  79.         foreach ($this->getIps() as $ip) {
  80.             $string $string $ip->getIp() . '<br>';
  81.         }
  82.         return $string;
  83.     }
  84.     public function getNiceName()
  85.     {
  86.         $string '';
  87.         $string $string $this->getName() . '<br>';
  88.         $string $string $this->getSystemId().'#' ;
  89.         return $string;
  90.     }
  91.     public function getServerStatusString()
  92.     {
  93.         switch ($this->getStatus()){
  94.             case 'initializing':
  95.                 return '<span class="text-danger">در حال ساخت</span>';
  96.                 break;
  97.             case 'running':
  98.                 return '<span class="text-success">روشن</span>';
  99.                 break;
  100.             case 'off':
  101.                 return '<span class="text-danger">خاموش</span>';
  102.             case 'starting':
  103.                 return '<span class="text-warning">در حال روشن شدن</span>';
  104.                 break;
  105.             default:
  106.                 return '<span class="text-danger">'.$this->getStatus().'</span>';
  107.                 break;
  108.         }
  109.     }
  110.     public function getSystemId(): ?string
  111.     {
  112.         return $this->systemId;
  113.     }
  114.     public function setSystemId(?string $systemId): static
  115.     {
  116.         $this->systemId $systemId;
  117.         return $this;
  118.     }
  119.     public function getName(): ?string
  120.     {
  121.         return $this->name;
  122.     }
  123.     public function setName(?string $name): static
  124.     {
  125.         $this->name $name;
  126.         return $this;
  127.     }
  128.     public function getStatus(): ?string
  129.     {
  130.         return $this->status;
  131.     }
  132.     public function setStatus(?string $status): static
  133.     {
  134.         $this->status $status;
  135.         return $this;
  136.     }
  137.     public function getOutgoingTraffic(): ?string
  138.     {
  139.         return $this->outgoingTraffic;
  140.     }
  141.     public function setOutgoingTraffic(?string $outgoingTraffic): static
  142.     {
  143.         $this->outgoingTraffic $outgoingTraffic;
  144.         return $this;
  145.     }
  146.     public function getIngoingTraffic(): ?string
  147.     {
  148.         return $this->ingoingTraffic;
  149.     }
  150.     public function setIngoingTraffic(?string $ingoingTraffic): static
  151.     {
  152.         $this->ingoingTraffic $ingoingTraffic;
  153.         return $this;
  154.     }
  155.     public function getIncludedTraffic(): ?string
  156.     {
  157.         return $this->includedTraffic;
  158.     }
  159.     public function setIncludedTraffic(?string $includedTraffic): static
  160.     {
  161.         $this->includedTraffic $includedTraffic;
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return Collection<int, Ip>
  166.      */
  167.     public function getIps(): Collection
  168.     {
  169.         return $this->ips;
  170.     }
  171.     public function addIp(Ip $ip): static
  172.     {
  173.         if (!$this->ips->contains($ip)) {
  174.             $this->ips->add($ip);
  175.             $ip->setServer($this);
  176.         }
  177.         return $this;
  178.     }
  179.     public function removeIp(Ip $ip): static
  180.     {
  181.         if ($this->ips->removeElement($ip)) {
  182.             // set the owning side to null (unless already changed)
  183.             if ($ip->getServer() === $this) {
  184.                 $ip->setServer(null);
  185.             }
  186.         }
  187.         return $this;
  188.     }
  189.     public function getOwner(): ?User
  190.     {
  191.         return $this->owner;
  192.     }
  193.     public function setOwner(?User $owner): static
  194.     {
  195.         $this->owner $owner;
  196.         return $this;
  197.     }
  198.     public function getServerType(): ?ServerType
  199.     {
  200.         return $this->serverType;
  201.     }
  202.     public function setServerType(?ServerType $serverType): static
  203.     {
  204.         $this->serverType $serverType;
  205.         return $this;
  206.     }
  207.     public function getDatacenter(): ?DataCenter
  208.     {
  209.         return $this->datacenter;
  210.     }
  211.     public function setDatacenter(?DataCenter $datacenter): static
  212.     {
  213.         $this->datacenter $datacenter;
  214.         return $this;
  215.     }
  216.     public function getImage(): ?Image
  217.     {
  218.         return $this->image;
  219.     }
  220.     public function setImage(?Image $image): static
  221.     {
  222.         $this->image $image;
  223.         return $this;
  224.     }
  225.     public function getRootPassword(): ?string
  226.     {
  227.         return $this->rootPassword;
  228.     }
  229.     public function setRootPassword(string $rootPassword): static
  230.     {
  231.         $this->rootPassword $rootPassword;
  232.         return $this;
  233.     }
  234.     public function isRescueEnabled(): ?bool
  235.     {
  236.         return $this->rescueEnabled;
  237.     }
  238.     public function setRescueEnabled(bool $rescueEnabled): static
  239.     {
  240.         $this->rescueEnabled $rescueEnabled;
  241.         return $this;
  242.     }
  243.     public function getPayMethod(): ?string
  244.     {
  245.         return $this->payMethod;
  246.     }
  247.     public function setPayMethod(?string $payMethod): static
  248.     {
  249.         $this->payMethod $payMethod;
  250.         return $this;
  251.     }
  252.     public function getPaidUntil(): ?\DateTimeInterface
  253.     {
  254.         return $this->paidUntil;
  255.     }
  256.     public function setPaidUntil(?\DateTimeInterface $paidUntil): static
  257.     {
  258.         $this->paidUntil $paidUntil;
  259.         return $this;
  260.     }
  261.     public function isIsPowerOn(): ?bool
  262.     {
  263.         return $this->isPowerOn;
  264.     }
  265.     public function setIsPowerOn(?bool $isPowerOn): static
  266.     {
  267.         $this->isPowerOn $isPowerOn;
  268.         return $this;
  269.     }
  270.     public function getLastRebuild(): ?\DateTimeInterface
  271.     {
  272.         return $this->lastRebuild;
  273.     }
  274.     public function setLastRebuild(?\DateTimeInterface $lastRebuild): static
  275.     {
  276.         $this->lastRebuild $lastRebuild;
  277.         return $this;
  278.     }
  279.     public function getAnalytics(): ?string
  280.     {
  281.         return $this->analytics;
  282.     }
  283.     public function setAnalytics(?string $analytics): static
  284.     {
  285.         $this->analytics $analytics;
  286.         return $this;
  287.     }
  288.     public function getActions(): ?string
  289.     {
  290.         return $this->actions;
  291.     }
  292.     public function setActions(?string $actions): static
  293.     {
  294.         $this->actions $actions;
  295.         return $this;
  296.     }
  297.     public function isIsSuspended(): ?bool
  298.     {
  299.         return $this->isSuspended;
  300.     }
  301.     public function setIsSuspended(bool $isSuspended): static
  302.     {
  303.         $this->isSuspended $isSuspended;
  304.         return $this;
  305.     }
  306.     public function getSuspendType(): ?string
  307.     {
  308.         return $this->suspendType;
  309.     }
  310.     public function setSuspendType(?string $suspendType): static
  311.     {
  312.         $this->suspendType $suspendType;
  313.         return $this;
  314.     }
  315. }