<?php
namespace App\Entity\Profil;
use App\Entity\EntityIdentifier;
use App\Repository\Profil\TwiceProfileRepository;
use Doctrine\ORM\Mapping as ORM;
use Knp\DoctrineBehaviors\Model as ORMBehaviors;
/**
* @ORM\Entity(repositoryClass=TwiceProfileRepository::class)
* @ORM\Table(uniqueConstraints={
* @ORM\UniqueConstraint(name="unique_couple_of_profile",columns={"profile_a_id", "profile_b_id"})
* })
* @ORM\HasLifecycleCallbacks()
*/
class TwiceProfile
{
use ORMBehaviors\Translatable\Translatable;
use EntityIdentifier;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity=TwiceProfileTranslation::class, mappedBy="translatable", cascade={"persist"})
*/
protected $newTranslations;
/**
* @ORM\ManyToOne(targetEntity=Profil::class, inversedBy="twiceProfilesA")
*/
private $profileA;
/**
* @ORM\ManyToOne(targetEntity=Profil::class, inversedBy="twiceProfilesB")
*/
private $profileB;
/**
* @ORM\PostLoad()
*/
public function init() {
$this->mergeNewTranslations();
$this->currentLocale = \Locale::getDefault();
}
public function __call($name, $arguments) {
$reflect = new \ReflectionClass(TwiceProfileTranslation::class);
$privateProperties = $reflect->getProperties(\ReflectionProperty::IS_PRIVATE);
foreach ($privateProperties as $property) {
if($property->getName() == $name) {
return $this->translate()->{"get" . ucfirst($name)}();
}
}
return "";
}
public function getId(): ?int
{
return $this->id;
}
public function getProfileA(): ?Profil
{
return $this->profileA;
}
public function setProfileA(?Profil $profileA): self
{
$this->profileA = $profileA;
return $this;
}
public function getProfileB(): ?Profil
{
return $this->profileB;
}
public function setProfileB(?Profil $profileB): self
{
$this->profileB = $profileB;
return $this;
}
}