src/Entity/Settings/Language.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Settings;
  3. use Symfony\Component\Validator\Constraints AS Constraints;
  4. use Symfony\Component\Validator\Constraints AS Assert;
  5. use Doctrine\ORM\Mapping AS ORM;
  6. use Ramsey\Uuid\Uuid;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\Settings\LanguageRepository")
  9.  * @ORM\Table(name="settings_language")
  10.  */
  11. class Language
  12. {
  13.     /**
  14.     * @ORM\Id
  15.     * @ORM\GeneratedValue(strategy="AUTO")
  16.     * @ORM\Column(type="integer")
  17.     */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="uuid")
  21.      * @Assert\Uuid
  22.      */
  23.      protected $uuid;
  24.     /**
  25.      * @var \DateTime
  26.      *
  27.      * @ORM\Column(type="datetime", nullable=false)
  28.      */
  29.     private $created;
  30.     /**
  31.      * @var \DateTime
  32.      *
  33.      * @ORM\Column(type="datetime", nullable=false)
  34.      */
  35.     private $modified;
  36.     /**
  37.      * @ORM\Column(type="string", length=2, nullable=false)
  38.      */
  39.     private $locale;
  40.     /**
  41.      * @ORM\Column(type="string", length=255, nullable=false)
  42.      */
  43.     private $name;
  44.     
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $icon;
  49.     /**
  50.      * @ORM\Column(type="boolean", nullable=false)
  51.      */
  52.     private $isLocked;
  53.     
  54.     /**
  55.      * @ORM\OneToMany(targetEntity="\App\Entity\Settings\Phrase", mappedBy="language", cascade={"all"})
  56.      **/
  57.     private $phrases;
  58.     public function __construct()
  59.     {
  60.         // UUID
  61.         if(!$this->getUuid())
  62.         {
  63.             $uuid Uuid::uuid1();
  64.             $this->setUuid($uuid->toString());
  65.         }
  66.         // Set some defaults
  67.         $this->setCreated(new \DateTime());
  68.         $this->setModified(new \DateTime());
  69.         $this->setIsLocked(false);
  70.     }
  71.     
  72.     /**
  73.      * @ORM\PrePersist()
  74.      * @ORM\PreUpdate()
  75.      */
  76.     public function updateModified()
  77.     {
  78.         // Update modified
  79.         $this->setModified(new \DateTime());
  80.     }
  81.     
  82.     public function getId()
  83.     {
  84.         return $this->id;
  85.     }
  86.     public function setUuid($uuid)
  87.     {
  88.         $this->uuid $uuid;
  89.         return $this;
  90.     }
  91.     public function getUuid()
  92.     {
  93.         return $this->uuid;
  94.     }
  95.     public function setCreated(\DateTime $created)
  96.     {
  97.         $this->created $created;
  98.     }
  99.     public function getCreated()
  100.     {
  101.         return $this->created;
  102.     }
  103.     public function setModified(\DateTime $modified)
  104.     {
  105.         $this->modified $modified;
  106.     }
  107.     public function getModified()
  108.     {
  109.         return $this->modified;
  110.     }
  111.     public function getLocale()
  112.     {
  113.         return $this->locale;
  114.     }
  115.     public function setLocale(string $locale)
  116.     {
  117.         $this->locale $locale;
  118.     }
  119.     public function getName()
  120.     {
  121.         return $this->name;
  122.     }
  123.     public function setName(string $name)
  124.     {
  125.         $this->name $name;
  126.     }
  127.     public function getIcon()
  128.     {
  129.         return $this->icon;
  130.     }
  131.     public function setIcon($icon)
  132.     {
  133.         $this->icon $icon;
  134.     }
  135.     
  136.     public function setIsLocked($isLocked)
  137.     {
  138.         $this->isLocked $isLocked;
  139.     }
  140.     public function getIsLocked()
  141.     {
  142.         return $this->isLocked;
  143.     }
  144.     public function getPhrases()
  145.     {
  146.         return $this->phrases;
  147.     }
  148. }