src/Entity/JobConfiguration/JobUserProfile.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\JobConfiguration;
  3. use App\Entity\EntityIdentifier;
  4. use App\Repository\JobConfiguration\JobUserProfileRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Knp\DoctrineBehaviors\Model as ORMBehaviors;
  7. /**
  8.  * @ORM\Entity(repositoryClass=JobUserProfileRepository::class)
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class JobUserProfile
  12. {
  13.     use ORMBehaviors\Translatable\Translatable;
  14.     
  15.     use EntityIdentifier;
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     
  23.     /**
  24.      * @ORM\OneToMany(targetEntity=JobUserProfileTranslation::class, mappedBy="translatable", cascade={"persist"})
  25.      */
  26.     protected $newTranslations;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $fullname;
  31.     /**
  32.      * @ORM\ManyToOne(targetEntity=Job::class, inversedBy="jobUserProfiles")
  33.      */
  34.     private $job;
  35.     /**
  36.      * @ORM\ManyToOne(targetEntity=Job::class, inversedBy="previousJobOfUsers")
  37.      */
  38.     private $previousJob;
  39.     
  40.     /**
  41.      * @ORM\PostLoad()
  42.      */
  43.     public function init() {
  44.                  $this->mergeNewTranslations();
  45.                  $this->currentLocale = \Locale::getDefault();
  46.              }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getFullname(): ?string
  52.     {
  53.         return $this->fullname;
  54.     }
  55.     public function setFullname(string $fullname): self
  56.     {
  57.         $this->fullname $fullname;
  58.         return $this;
  59.     }
  60.     public function getJob(): ?Job
  61.     {
  62.         return $this->job;
  63.     }
  64.     public function setJob(?Job $job): self
  65.     {
  66.         $this->job $job;
  67.         return $this;
  68.     }
  69.     
  70.     public function __call($name$arguments) {
  71.                  $reflect = new \ReflectionClassJobUserProfileTranslation::class);
  72.                  $privateProperties $reflect->getProperties(\ReflectionProperty::IS_PRIVATE);
  73.                  
  74.                  foreach ($privateProperties as $property) {
  75.                      if($property->getName() == $name) {
  76.                          return $this->translate()->{"get" ucfirst($name)}();
  77.                      }
  78.                  }
  79.                  
  80.                  return "";
  81.              }
  82.     public function getPreviousJob(): ?Job
  83.     {
  84.         return $this->previousJob;
  85.     }
  86.     public function setPreviousJob(?Job $previousJob): self
  87.     {
  88.         $this->previousJob $previousJob;
  89.         return $this;
  90.     }
  91. }