<?php
namespace App\Entity\Profil;
use App\Entity\EntityIdentifier;
use App\Entity\Quiz\RiasecBigFive\RBQuiz;
use App\Repository\Profil\BigFiveProfileRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
/**
* @ORM\Entity(repositoryClass=BigFiveProfileRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class BigFiveProfile
{
use ORMBehaviors\Translatable\Translatable;
use EntityIdentifier;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity=BigFiveProfileTranslation::class, mappedBy="translatable", cascade={"persist"})
*/
protected $newTranslations;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $color;
/**
* @ORM\OneToMany(targetEntity=RBQuiz::class, mappedBy="bigFiveProfile")
*/
private $rBQuizzes;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $position;
public function __construct()
{
$this->rBQuizzes = new ArrayCollection();
}
/**
* @ORM\PostLoad()
*/
public function init() {
$this->mergeNewTranslations();
$this->currentLocale = \Locale::getDefault();
}
public function getId(): ?int
{
return $this->id;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(?string $color): self
{
$this->color = $color;
return $this;
}
public function __call($name, $arguments) {
$reflect = new \ReflectionClass(BigFiveProfileTranslation::class);
$privateProperties = $reflect->getProperties(\ReflectionProperty::IS_PRIVATE);
foreach ($privateProperties as $property) {
if($property->getName() == $name) {
return $this->translate()->{"get" . ucfirst($name)}();
}
}
return "";
}
/**
* @return Collection<int, RBQuiz>
*/
public function getRBQuizzes(): Collection
{
return $this->rBQuizzes;
}
public function addRBQuiz(RBQuiz $rBQuiz): self
{
if (!$this->rBQuizzes->contains($rBQuiz)) {
$this->rBQuizzes[] = $rBQuiz;
$rBQuiz->setBigFiveProfile($this);
}
return $this;
}
public function removeRBQuiz(RBQuiz $rBQuiz): self
{
if ($this->rBQuizzes->removeElement($rBQuiz)) {
// set the owning side to null (unless already changed)
if ($rBQuiz->getBigFiveProfile() === $this) {
$rBQuiz->setBigFiveProfile(null);
}
}
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
}