chore: create base entities
This commit is contained in:
100
src/Entity/ResourceType.php
Normal file
100
src/Entity/ResourceType.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user