src/Entity/Profil/ProfilNegativeDescription.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Profil;
  3. use App\Entity\EntityIdentifier;
  4. use App\Entity\User;
  5. use App\Repository\Profil\ProfilNegativeDescriptionRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Knp\DoctrineBehaviors\Model as ORMBehaviors;
  10. /**
  11.  * @ORM\Entity(repositoryClass=ProfilNegativeDescriptionRepository::class)
  12.  * @ORM\HasLifecycleCallbacks()
  13.  */
  14. class ProfilNegativeDescription
  15. {
  16.     
  17.     use ORMBehaviors\Translatable\Translatable;
  18.     
  19.     use EntityIdentifier;
  20.     
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue
  24.      * @ORM\Column(type="integer")
  25.      */
  26.     private $id;
  27.     
  28.     /**
  29.      * @ORM\OneToMany(targetEntity=ProfilNegativeDescriptionTranslation::class, mappedBy="translatable", cascade={"persist"})
  30.      */
  31.     protected $newTranslations;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity=Profil::class, inversedBy="profilNegativeDescriptions")
  34.      */
  35.     private $profil;
  36.     /**
  37.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="negativeDescriptionChoices")
  38.      */
  39.     private $users;
  40.     /**
  41.      * @ORM\Column(type="integer", nullable=true)
  42.      */
  43.     private $position;
  44.     public function __construct()
  45.     {
  46.         $this->users = new ArrayCollection();
  47.     }
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getProfil(): ?Profil
  53.     {
  54.         return $this->profil;
  55.     }
  56.     public function setProfil(?Profil $profil): self
  57.     {
  58.         $this->profil $profil;
  59.         return $this;
  60.     }
  61.     
  62.     /**
  63.      * @ORM\PostLoad()
  64.      */
  65.     public function init() {
  66.                                             $this->mergeNewTranslations();
  67.                                             $this->currentLocale = \Locale::getDefault();
  68.                                         }
  69.     
  70.     public function __call($name$arguments) {
  71.                                             $reflect = new \ReflectionClass(ProfilNegativeDescriptionTranslation::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.     /**
  83.      * @return Collection<int, User>
  84.      */
  85.     public function getUsers(): Collection
  86.     {
  87.         return $this->users;
  88.     }
  89.     public function addUser(User $user): self
  90.     {
  91.         if (!$this->users->contains($user)) {
  92.             $this->users[] = $user;
  93.             $user->addNegativeDescriptionChoice($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeUser(User $user): self
  98.     {
  99.         if ($this->users->removeElement($user)) {
  100.             $user->removeNegativeDescriptionChoice($this);
  101.         }
  102.         return $this;
  103.     }
  104.     public function getPosition(): ?int
  105.     {
  106.         return $this->position;
  107.     }
  108.     public function setPosition(?int $position): self
  109.     {
  110.         $this->position $position;
  111.         return $this;
  112.     }
  113. }