src/Entity/Profil/TwiceProfile.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Profil;
  3. use App\Entity\EntityIdentifier;
  4. use App\Repository\Profil\TwiceProfileRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Knp\DoctrineBehaviors\Model as ORMBehaviors;
  7. /**
  8.  * @ORM\Entity(repositoryClass=TwiceProfileRepository::class)
  9.  *  @ORM\Table(uniqueConstraints={
  10.  *  @ORM\UniqueConstraint(name="unique_couple_of_profile",columns={"profile_a_id", "profile_b_id"})
  11.  * })
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. class TwiceProfile
  15. {
  16.     use ORMBehaviors\Translatable\Translatable;
  17.     
  18.     use EntityIdentifier;
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=TwiceProfileTranslation::class, mappedBy="translatable", cascade={"persist"})
  28.      */
  29.     protected $newTranslations;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=Profil::class, inversedBy="twiceProfilesA")
  32.      */
  33.     private $profileA;
  34.     /**
  35.      * @ORM\ManyToOne(targetEntity=Profil::class, inversedBy="twiceProfilesB")
  36.      */
  37.     private $profileB;
  38.     
  39.     /**
  40.      * @ORM\PostLoad()
  41.      */
  42.     public function init() {
  43.         $this->mergeNewTranslations();
  44.         $this->currentLocale = \Locale::getDefault();
  45.     }
  46.     
  47.     public function __call($name$arguments) {
  48.         $reflect = new \ReflectionClass(TwiceProfileTranslation::class);
  49.         $privateProperties $reflect->getProperties(\ReflectionProperty::IS_PRIVATE);
  50.         
  51.         foreach ($privateProperties as $property) {
  52.             if($property->getName() == $name) {
  53.                 return $this->translate()->{"get" ucfirst($name)}();
  54.             }
  55.         }
  56.         
  57.         return "";
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getProfileA(): ?Profil
  64.     {
  65.         return $this->profileA;
  66.     }
  67.     public function setProfileA(?Profil $profileA): self
  68.     {
  69.         $this->profileA $profileA;
  70.         return $this;
  71.     }
  72.     public function getProfileB(): ?Profil
  73.     {
  74.         return $this->profileB;
  75.     }
  76.     public function setProfileB(?Profil $profileB): self
  77.     {
  78.         $this->profileB $profileB;
  79.         return $this;
  80.     }
  81. }