<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\CompanyFormGroupRepository")
*/
class CompanyFormGroup
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var string
*
* @ORM\Column(type="string", length=128, nullable=true)
* @Assert\Length(max="128")
* @Assert\NotBlank()
*/
private $title;
/**
* @var string
*
* @ORM\Column(type="string", length=128)
* @Assert\Length(max="128")
* @Assert\NotBlank()
*/
private $label;
/**
* @var int
*
* @ORM\Column(type="integer")
* @Assert\NotBlank()
* @Assert\Type(type="integer")
*/
private $position;
/**
* @var CompanyFormPage
*
* @ORM\ManyToOne(targetEntity="App\Entity\CompanyFormPage", inversedBy="formGroups")
* @ORM\JoinColumn(onDelete="CASCADE")
* @Assert\NotNull()
*/
private $formPage;
/**
* @var ArrayCollection
*
* @ORM\OneToMany(targetEntity="App\Entity\CompanyFormQuestion", mappedBy="formGroup", cascade={"persist"})
*/
private $formQuestions;
/**
* CompanyFormGroup constructor.
*
* @throws \Exception
*/
public function __construct()
{
$this->formQuestions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
/**
* @return Collection|CompanyFormQuestion[]
*/
public function getFormQuestions(): Collection
{
return $this->formQuestions;
}
public function addFormQuestion(CompanyFormQuestion $formQuestion): self
{
if (!$this->formQuestions->contains($formQuestion)) {
$this->formQuestions[] = $formQuestion;
$formQuestion->setFormGroup($this);
}
return $this;
}
public function removeFormQuestion(CompanyFormQuestion $formQuestion): self
{
if ($this->formQuestions->contains($formQuestion)) {
$this->formQuestions->removeElement($formQuestion);
// set the owning side to null (unless already changed)
if ($formQuestion->getFormGroup() === $this) {
$formQuestion->setFormGroup(null);
}
}
return $this;
}
public function getFormPage(): ?CompanyFormPage
{
return $this->formPage;
}
public function setFormPage(?CompanyFormPage $formPage): self
{
$this->formPage = $formPage;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
}