<?php
namespace App\Entity;
use App\Repository\InstanceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\SiteConfig;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Represents an Instance entity.
*
* @ORM\Entity(repositoryClass=InstanceRepository::class)
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(columns={"name"})})
* @ORM\Table(uniqueConstraints={@ORM\UniqueConstraint(columns={"code"})})
*/
class Instance
{
/**
* @var int|null The unique identifier of the instance.
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @var string The name of the instance.
* @ORM\Column(type="string", length=255, unique=true)
*/
private string $name;
/**
* @var bool Whether the instance is activated or not.
* @ORM\Column(type="boolean")
*/
private bool $isActivated = true;
/**
* @var Collection<int, Criteria1Item> Collection of Criteria1Items associated with this instance.
* @ORM\ManyToMany(targetEntity=Criteria1Item::class, inversedBy="instances")
*/
private Collection $criteria1Items;
/**
* @var Collection<int, Criteria2Item> Collection of Criteria2Items associated with this instance.
* @ORM\ManyToMany(targetEntity=Criteria2Item::class, inversedBy="instances")
*/
private Collection $criteria2Items;
/**
* @var Collection<int, Criteria3Item> Collection of Criteria3Items associated with this instance.
* @ORM\ManyToMany(targetEntity=Criteria3Item::class, inversedBy="instances")
*/
private Collection $criteria3Items;
/**
* @var Collection<int, Criteria4Item> Collection of Criteria3Items associated with this instance.
* @ORM\ManyToMany(targetEntity=Criteria4Item::class, inversedBy="instances")
*/
private Collection $criteria4Items;
/**
* @var Collection<int, Criteria5Item> Collection of Criteria3Items associated with this instance.
* @ORM\ManyToMany(targetEntity=Criteria5Item::class, inversedBy="instances")
*/
private Collection $criteria5Items;
/**
* @var Collection<int, User> Collection of Users associated with this instance.
* @ORM\ManyToMany(targetEntity=User::class, mappedBy="instances")
*/
private Collection $users;
/**
* @var Collection<int, BlogPostCategory> Collection of BlogPostCategories associated with this instance.
* @ORM\ManyToMany(targetEntity=BlogPostCategory::class, mappedBy="instances")
*/
private Collection $blogPostCategories;
/**
* @var Collection<int, BlogPost> Collection of BlogPosts associated with this instance.
* @ORM\ManyToMany(targetEntity=BlogPost::class, mappedBy="instances")
*/
private Collection $blogPosts;
/**
* @var Collection<int, Radio> Collection of Radios associated with this instance.
* @ORM\ManyToMany(targetEntity=Radio::class, mappedBy="instances")
*/
private Collection $radios;
/**
* @var Collection<int, SiteConfig> Collection of SiteConfigs associated with this instance.
* @ORM\OneToMany(targetEntity=SiteConfig::class, mappedBy="instance")
*/
private Collection $siteConfigs;
/**
* @var Collection<int, SiteCustomization> Collection of SiteCustomizations associated with this instance.
* @ORM\OneToMany(targetEntity=SiteCustomization::class, mappedBy="instance")
*/
/**
* @ORM\Column(type="string", length=255, unique=true)
* @Assert\NotBlank(message="Le code de l'instance est obligatoire")
*/
private $code;
private Collection $siteCustomizations;
public function __construct()
{
$this->criteria1Items = new ArrayCollection();
$this->criteria2Items = new ArrayCollection();
$this->criteria3Items = new ArrayCollection();
$this->criteria4Items = new ArrayCollection();
$this->criteria5Items = new ArrayCollection();
$this->users = new ArrayCollection();
$this->blogPostCategories = new ArrayCollection();
$this->blogPosts = new ArrayCollection();
$this->radios = new ArrayCollection();
$this->siteConfigs = new ArrayCollection();
$this->siteCustomizations = new ArrayCollection();
}
/**
* Get the instance ID.
*
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* Get the instance name.
*
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* Set the instance name.
*
* @param string $name
* @return self
*/
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* Check if the instance is activated.
*
* @return bool
*/
public function isActivated(): bool
{
return $this->isActivated;
}
/**
* Set the instance activation status.
*
* @param bool $isActivated
* @return self
*/
public function setIsActivated(bool $isActivated): self
{
$this->isActivated = $isActivated;
return $this;
}
/**
* @return Collection<int, Criteria1Item>
*/
public function getCriteria1Items(): Collection
{
return $this->criteria1Items;
}
public function addCriteria1Item(Criteria1Item $criteria1Item): self
{
if (!$this->criteria1Items->contains($criteria1Item)) {
$this->criteria1Items[] = $criteria1Item;
}
return $this;
}
public function removeCriteria1Item(Criteria1Item $criteria1Item): self
{
$this->criteria1Items->removeElement($criteria1Item);
return $this;
}
/**
* @return Collection<int, Criteria2Item>
*/
public function getCriteria2Items(): Collection
{
return $this->criteria2Items;
}
public function addCriteria2Item(Criteria2Item $criteria2Item): self
{
if (!$this->criteria2Items->contains($criteria2Item)) {
$this->criteria2Items[] = $criteria2Item;
}
return $this;
}
public function removeCriteria2Item(Criteria2Item $criteria2Item): self
{
$this->criteria2Items->removeElement($criteria2Item);
return $this;
}
/**
* @return Collection<int, Criteria3Item>
*/
public function getCriteria3Items(): Collection
{
return $this->criteria3Items;
}
public function addCriteria3Item(Criteria3Item $criteria3Item): self
{
if (!$this->criteria3Items->contains($criteria3Item)) {
$this->criteria3Items[] = $criteria3Item;
}
return $this;
}
public function removeCriteria3Item(Criteria3Item $criteria3Item): self
{
$this->criteria3Items->removeElement($criteria3Item);
return $this;
}
/**
* @return Collection<int, Criteria4Item>
*/
public function getCriteria4Items(): Collection
{
return $this->criteria4Items;
}
public function addCriteria4Item(Criteria4Item $criteria4Item): self
{
if (!$this->criteria4Items->contains($criteria4Item)) {
$this->criteria4Items[] = $criteria4Item;
}
return $this;
}
public function removeCriteria4Item(Criteria4Item $criteria4Item): self
{
$this->criteria4Items->removeElement($criteria4Item);
return $this;
}
/**
* @return Collection<int, Criteria5Item>
*/
public function getCriteria5Items(): Collection
{
return $this->criteria5Items;
}
public function addCriteria5Item(Criteria5Item $criteria5Item): self
{
if (!$this->criteria5Items->contains($criteria5Item)) {
$this->criteria5Items[] = $criteria5Item;
}
return $this;
}
public function removeCriteria5Item(Criteria5Item $criteria5Item): self
{
$this->criteria5Items->removeElement($criteria5Item);
return $this;
}
/**
* Get the string representation of the instance.
*
* @return string
*/
public function __toString(): string
{
return $this->name;
}
/**
* Get the collection of Users.
*
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
/**
* Add a User to the instance.
*
* @param User $user
* @return self
*/
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addInstance($this);
}
return $this;
}
/**
* Remove a User from the instance.
*
* @param User $user
* @return self
*/
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
$user->removeInstance($this);
}
return $this;
}
/**
* @return Collection<int, BlogPostCategory>
*/
public function getBlogPostCategories(): Collection
{
return $this->blogPostCategories;
}
public function addBlogPostCategory(BlogPostCategory $blogPostCategory): self
{
if (!$this->blogPostCategories->contains($blogPostCategory)) {
$this->blogPostCategories[] = $blogPostCategory;
$blogPostCategory->addInstance($this);
}
return $this;
}
public function removeBlogPostCategory(BlogPostCategory $blogPostCategory): self
{
if ($this->blogPostCategories->removeElement($blogPostCategory)) {
$blogPostCategory->removeInstance($this);
}
return $this;
}
/**
* @return Collection<int, BlogPost>
*/
public function getBlogPosts(): Collection
{
return $this->blogPosts;
}
public function addBlogPost(BlogPost $blogPost): self
{
if (!$this->blogPosts->contains($blogPost)) {
$this->blogPosts[] = $blogPost;
$blogPost->addInstance($this);
}
return $this;
}
public function removeBlogPost(BlogPost $blogPost): self
{
if ($this->blogPosts->removeElement($blogPost)) {
$blogPost->removeInstance($this);
}
return $this;
}
/**
* @return Collection<int, Radio>
*/
public function getRadios(): Collection
{
return $this->radios;
}
public function addRadio(Radio $radio): self
{
if (!$this->radios->contains($radio)) {
$this->radios[] = $radio;
$radio->addInstance($this);
}
return $this;
}
public function removeRadio(Radio $radio): self
{
if ($this->radios->removeElement($radio)) {
$radio->removeInstance($this);
}
return $this;
}
/**
* @return Collection<int, SiteConfig>
*/
public function getSiteConfigs(): Collection
{
return $this->siteConfigs;
}
public function addSiteConfig(SiteConfig $siteConfig): self
{
if (!$this->siteConfigs->contains($siteConfig)) {
$this->siteConfigs[] = $siteConfig;
$siteConfig->setInstance($this);
}
return $this;
}
public function removeSiteConfig(SiteConfig $siteConfig): self
{
if ($this->siteConfigs->removeElement($siteConfig)) {
// set the owning side to null (unless already changed)
if ($siteConfig->getInstance() === $this) {
$siteConfig->setInstance(null);
}
}
return $this;
}
public function getSiteConfig(): ?SiteConfig
{
return $this->siteConfigs->first() ?: null;
}
/**
* @return Collection<int, SiteCustomization>
*/
public function getSiteCustomizations(): Collection
{
return $this->siteCustomizations;
}
public function addSiteCustomization(SiteCustomization $siteCustomization): self
{
if (!$this->siteCustomizations->contains($siteCustomization)) {
$this->siteCustomizations[] = $siteCustomization;
$siteCustomization->setInstance($this);
}
return $this;
}
public function removeSiteCustomization(SiteCustomization $siteCustomization): self
{
if ($this->siteCustomizations->removeElement($siteCustomization)) {
// set the owning side to null (unless already changed)
if ($siteCustomization->getInstance() === $this) {
$siteCustomization->setInstance(null);
}
}
return $this;
}
public function getSiteCustomization(): ?SiteCustomization
{
return $this->siteCustomizations->first() ?: null;
}
/**
* Get the instance code.
*
* @return string|null
*/
public function getCode(): ?string
{
return $this->code;
}
/**
* Set the instance code.
*
* @param string $code
* @return self
*/
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
}