janus/src/Entity/ResourceType.php

101 lines
2.0 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\ResourceTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ResourceTypeRepository::class)
*/
class ResourceType
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $validationSchema = [];
/**
* @ORM\OneToMany(targetEntity=Resource::class, mappedBy="type", orphanRemoval=true)
*/
private $Resources;
public function __construct()
{
$this->Resources = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getValidationSchema(): ?array
{
return $this->validationSchema;
}
public function setValidationSchema(?array $validationSchema): self
{
$this->validationSchema = $validationSchema;
return $this;
}
/**
* @return Collection|Resource[]
*/
public function getResources(): Collection
{
return $this->Resources;
}
public function addResource(Resource $resource): self
{
if (!$this->Resources->contains($resource)) {
$this->Resources[] = $resource;
$resource->setType($this);
}
return $this;
}
public function removeResource(Resource $resource): self
{
if ($this->Resources->removeElement($resource)) {
// set the owning side to null (unless already changed)
if ($resource->getType() === $this) {
$resource->setType(null);
}
}
return $this;
}
}