vendor/elcoag/symfony-process-bundle/src/Entity/Server.php line 19

  1. <?php
  2. namespace Elcoag\SymfonyProcessBundle\Entity;
  3. use Symfony\Component\Serializer\Annotation\Ignore;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use Symfony\Component\Form\Extension\Core\Type\DateType;
  6. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use ApiPlatform\Metadata\ApiResource;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Elcoag\SymfonyAdminlteBundle\Annotations\FieldType;
  13. use Elcoag\SymfonyProcessBundle\Repository\ServerRepository;
  14. #[ORM\Entity(repositoryClassServerRepository::class)]
  15. #[ApiResource]
  16. class Server
  17. {
  18.     /**
  19.      * @var array
  20.      *
  21.      * @Assert\Type("array")
  22.      * @FieldType(type="Symfony\Component\Form\Extension\Core\Type\CollectionType", options={"row_attr":"d-none"})
  23.      */
  24.     private array $attributes = [
  25.         'id',
  26.         'name',
  27.         'createdAt',
  28.         'updatedAt',
  29.         'actions',
  30.     ];
  31.     public function getAttributes(): array
  32.     {
  33.         return $this->attributes;
  34.     }
  35.     /**
  36.      * @var ?int
  37.      *
  38.      * @Assert\Type("int")
  39.      * @FieldType(type="Symfony\Component\Form\Extension\Core\Type\HiddenType")
  40.      */
  41.     #[ORM\Id]
  42.     #[ORM\GeneratedValue]
  43.     #[ORM\Column]
  44.     private ?int $id null;
  45.     /**
  46.      * @var string
  47.      *
  48.      * @Assert\NotBlank(message="Required field")
  49.      * @Assert\Type("string")
  50.      * @FieldType(type="Symfony\Component\Form\Extension\Core\Type\TextType", options={"row_attr":"clear-left"})
  51.      */
  52.     #[ORM\Column(length255)]
  53.     private ?string $name null;
  54.     /**
  55.      * @var ?\DateTime
  56.      *
  57.      * @Assert\NotBlank(message="Required field")
  58.      * @Assert\Type("DateTime")
  59.      * @FieldType(type="Symfony\Component\Form\Extension\Core\Type\DateTimeType", options={"row_attr":"clear-left"})
  60.      */
  61.     #[ORM\Column]
  62.     private ?\DateTime $created_at null;
  63.     /**
  64.      * @var ?\DateTime
  65.      *
  66.      * @Assert\NotBlank(message="Required field")
  67.      * @Assert\Type("DateTime")
  68.      * @FieldType(type="Symfony\Component\Form\Extension\Core\Type\DateTimeType", options={"row_attr":"clear-left"})
  69.      */
  70.     #[ORM\Column]
  71.     private ?\DateTime $updated_at null;
  72.     #[ORM\OneToMany(mappedBy'server'targetEntityProcess::class)]
  73.     private Collection $processes;
  74.     public function __construct()
  75.     {
  76.         $this->processes = new ArrayCollection();
  77.     }
  78.     public function getId(): ?int
  79.     {
  80.         return $this->id;
  81.     }
  82.     public function setId(string $id): self
  83.     {
  84.         $this->id $id;
  85.         return $this;
  86.     }
  87.     public function getName(): ?string
  88.     {
  89.         return $this->name;
  90.     }
  91.     public function setName(string $name): self
  92.     {
  93.         $this->name $name;
  94.         return $this;
  95.     }
  96.     public function getCreatedAt(): ?\DateTime
  97.     {
  98.         return $this->created_at;
  99.     }
  100.     public function setCreatedAt(\DateTime $created_at): self
  101.     {
  102.         $this->created_at $created_at;
  103.         return $this;
  104.     }
  105.     public function getUpdatedAt(): ?\DateTime
  106.     {
  107.         return $this->updated_at;
  108.     }
  109.     public function setUpdatedAt(\DateTime $updated_at): self
  110.     {
  111.         $this->updated_at $updated_at;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return Collection<int, Process>
  116.      */
  117.     public function getProcesses(): Collection
  118.     {
  119.         return $this->processes;
  120.     }
  121.     public function addProcess(Process $process): self
  122.     {
  123.         if (!$this->processes->contains($process)) {
  124.             $this->processes->add($process);
  125.             $process->setServer($this);
  126.         }
  127.         return $this;
  128.     }
  129.     public function removeProcess(Process $process): self
  130.     {
  131.         if ($this->processes->removeElement($process)) {
  132.             // set the owning side to null (unless already changed)
  133.             if ($process->getServer() === $this) {
  134.                 $process->setServer(null);
  135.             }
  136.         }
  137.         return $this;
  138.     }
  139. }