<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\FormRepository")
*/
class Form
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="bigint")
*/
private $id;
/**
* @ORM\Version @ORM\Column(type="integer")
*/
private $version;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\OneToMany(targetEntity="App\Entity\FormField", mappedBy="form", orphanRemoval=true, cascade={"persist", "remove"}, fetch="EAGER")
*/
private $formFields;
public function __construct()
{
$this->title = "";
$this->formFields = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function getVersion() {
return $this->version;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title = null): self
{
$this->title = $title ? $title : "";
return $this;
}
/**
* @return Collection|FormField[]
*/
public function getFormFields(): Collection
{
return $this->formFields;
}
public function addFormField(FormField $formField): self
{
if (!$this->formFields->contains($formField)) {
$this->formFields[] = $formField;
$formField->setForm($this);
}
return $this;
}
public function removeFormField(FormField $formField): self
{
if ($this->formFields->contains($formField)) {
$this->formFields->removeElement($formField);
// set the owning side to null (unless already changed)
if ($formField->getForm() === $this) {
$formField->setForm(null);
}
}
return $this;
}
public function __toString ()
{
return $this->title ? $this->title : '';
}
}