<?php
namespace App\Entity\Profil;
use App\Entity\EntityIdentifier;
use App\Entity\User;
use App\Repository\Profil\ProfilNegativeDescriptionRepository;
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=ProfilNegativeDescriptionRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class ProfilNegativeDescription
{
use ORMBehaviors\Translatable\Translatable;
use EntityIdentifier;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity=ProfilNegativeDescriptionTranslation::class, mappedBy="translatable", cascade={"persist"})
*/
protected $newTranslations;
/**
* @ORM\ManyToOne(targetEntity=Profil::class, inversedBy="profilNegativeDescriptions")
*/
private $profil;
/**
* @ORM\ManyToMany(targetEntity=User::class, mappedBy="negativeDescriptionChoices")
*/
private $users;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $position;
public function __construct()
{
$this->users = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getProfil(): ?Profil
{
return $this->profil;
}
public function setProfil(?Profil $profil): self
{
$this->profil = $profil;
return $this;
}
/**
* @ORM\PostLoad()
*/
public function init() {
$this->mergeNewTranslations();
$this->currentLocale = \Locale::getDefault();
}
public function __call($name, $arguments) {
$reflect = new \ReflectionClass(ProfilNegativeDescriptionTranslation::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, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addNegativeDescriptionChoice($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
$user->removeNegativeDescriptionChoice($this);
}
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
}