<?php
namespace App\Entity;
use App\Repository\CertificatesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=CertificatesRepository::class)
* @UniqueEntity(
* fields={"name"},
* message="Certificate with name (%s) is already registered"
* )
*/
class Certificates
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "certificates.base",
* "partner.certificate.manage",
* "partner.manage.base",
* "project.certificates",
* "partner.joined.projects.depended.certificates",
* "stakeholder.selected.core.project.manage",
* "worker.manage.base",
* "worker.certificate.manage",
* "selected.partner.project.for.worker",
*
* "certificate@core"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "certificates.base",
* "partner.certificate.manage",
* "partner.manage.base",
* "project.certificates",
* "partner.joined.projects.depended.certificates",
* "stakeholder.selected.core.project.manage",
* "worker.manage.base",
* "worker.certificate.manage",
* "selected.partner.project.for.worker",
*
* "certificate@core"
*
* })
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true )
* @Groups({
* "certificates.base",
* "partner.manage.base",
* "project.certificates",
* "partner.joined.projects.depended.certificates",
* "stakeholder.selected.core.project.manage",
* "worker.manage.base",
* "worker.certificate.manage",
* "selected.partner.project.for.worker",
*
* "certificate@core"
*
* })
*/
private $color;
/**
* @ORM\OneToMany(targetEntity=WorkerCertificates::class, mappedBy="certificate")
*/
private $workerCertificates;
/**
* @ORM\ManyToOne(targetEntity=CertificatesGroups::class, inversedBy="certificates")
* @ORM\JoinColumn(nullable=false)
* @Groups({
* "certificate.group.base",
*
* "certificate@groups"
* })
*/
private $groups;
/**
* @ORM\OneToMany(targetEntity=PartnerCertificates::class, mappedBy="certificate")
*/
private $partnerCertificates;
/**
* @ORM\ManyToMany(targetEntity=ProjectStakeholders::class, mappedBy="dependent_certificates")
*/
private $project_stakeholders;
/**
* @ORM\ManyToMany(targetEntity=Projects::class, mappedBy="dependent_certificates")
*/
private $projects;
/**
* @ORM\ManyToOne(targetEntity=CertificateEligibilities::class, inversedBy="certificates")
* @Groups({"certificates.base", "project.certificates", "partner.joined.projects.depended.certificates.eligibility"})
* @ORM\JoinColumn(nullable=true)
*/
private $certificate_eligibility;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $created_at;
public function __construct()
{
$this->workerCertificates = new ArrayCollection();
$this->partnerCertificates = new ArrayCollection();
$this->project_stakeholders = new ArrayCollection();
$this->projects = 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 getColor(): ?string
{
return $this->color;
}
public function setColor(string $color): self
{
$this->color = $color;
return $this;
}
/**
* @return Collection<int, WorkerCertificates>
*/
// public function getWorkerCertificates(): Collection
// {
// return $this->workerCertificates;
// }
public function addWorkerCertificate(WorkerCertificates $workerCertificate): self
{
if (!$this->workerCertificates->contains($workerCertificate)) {
$this->workerCertificates[] = $workerCertificate;
$workerCertificate->setCertificate($this);
}
return $this;
}
public function removeWorkerCertificate(WorkerCertificates $workerCertificate): self
{
if ($this->workerCertificates->removeElement($workerCertificate)) {
// set the owning side to null (unless already changed)
if ($workerCertificate->getCertificate() === $this) {
$workerCertificate->setCertificate(null);
}
}
return $this;
}
// public function getGroups(): ?CertificatesGroups
// {
// return $this->groups;
// }
public function setGroups(?CertificatesGroups $groups): self
{
$this->groups = $groups;
return $this;
}
/**
* @return Collection<int, PartnerCertificates>
*/
// public function getPartnerCertificates(): Collection
// {
// return $this->partnerCertificates;
// }
public function addPartnerCertificate(PartnerCertificates $partnerCertificate): self
{
if (!$this->partnerCertificates->contains($partnerCertificate)) {
$this->partnerCertificates[] = $partnerCertificate;
$partnerCertificate->setCertificate($this);
}
return $this;
}
public function removePartnerCertificate(PartnerCertificates $partnerCertificate): self
{
if ($this->partnerCertificates->removeElement($partnerCertificate)) {
// set the owning side to null (unless already changed)
if ($partnerCertificate->getCertificate() === $this) {
$partnerCertificate->setCertificate(null);
}
}
return $this;
}
/**
* @return Collection<int, ProjectStakeholders>
*/
// public function getProjectStakeholders(): Collection
// {
// return $this->projectStakeholders;
// }
public function addProjectStakeholder(ProjectStakeholders $projectStakeholder): self
{
if (!$this->project_stakeholders->contains($projectStakeholder)) {
$this->project_stakeholders[] = $projectStakeholder;
$projectStakeholder->addDependentCertificate($this);
}
return $this;
}
public function removeProjectStakeholder(ProjectStakeholders $projectStakeholder): self
{
if ($this->project_stakeholders->removeElement($projectStakeholder)) {
$projectStakeholder->removeDependentCertificate($this);
}
return $this;
}
/**
* @return Collection<int, Projects>
*/
// public function getProjects(): Collection
// {
// return $this->projects;
// }
public function addProject(Projects $project): self
{
if (!$this->projects->contains($project)) {
$this->projects[] = $project;
$project->addDependentCertificate($this);
}
return $this;
}
public function removeProject(Projects $project): self
{
if ($this->projects->removeElement($project)) {
$project->removeDependentCertificate($this);
}
return $this;
}
public function getCertificateEligibility(): ?CertificateEligibilities
{
return $this->certificate_eligibility;
}
public function setCertificateEligibility(?CertificateEligibilities $certificate_eligibility): self
{
$this->certificate_eligibility = $certificate_eligibility;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(?\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
}