src/CoreBundle/Entity/Language.php line 18

Open in your IDE?
  1. <?php
  2. namespace Core\Entity;
  3. use Core\Entity\Traits\EntityTrait;
  4. use Core\Entity\Traits\TranslatableTrait;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. /**
  9.  * Langues disponibles de l'application
  10.  *
  11.  * @Vich\Uploadable
  12.  * @ORM\Entity(repositoryClass="Core\Repository\LanguageRepository")
  13.  * @ORM\Table(name="core_language")
  14.  */
  15. class Language
  16. {
  17.     use TranslatableTrait;
  18.     use EntityTrait {
  19.         EntityTrait::__construct as private __entityConstruct;
  20.     }
  21.     /**
  22.      * @ORM\Column(type="boolean", length=255, nullable=true)
  23.      */
  24.     private $is_default;
  25.     /**
  26.      * Code de langue
  27.      *
  28.      * @ORM\Column(type="string", length=255, nullable=true)
  29.      */
  30.     private $language_code;
  31.     /**
  32.      * Code ISO
  33.      *
  34.      * @ORM\Column(type="string", length=255, nullable=true)
  35.      */
  36.     private $iso_code;
  37.     /**
  38.      * Petit format de date
  39.      *
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private $date_format;
  43.     /**
  44.      * Format complet de date
  45.      *
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $date_format_full;
  49.     /**
  50.      * Image du drapeau
  51.      *
  52.      * @ORM\Column(type="string", length=255, nullable=true)
  53.      * @var string
  54.      */
  55.     private $image;
  56.     /**
  57.      * @Vich\UploadableField(mapping="images", fileNameProperty="image")
  58.      * @var File
  59.      */
  60.     private $imageFile;
  61.     /**
  62.      * Constructeur
  63.      * @throws \Exception
  64.      */
  65.     public function __construct()
  66.     {
  67.         $this->__entityConstruct();
  68.         $this->setIsDefault(false);
  69.     }
  70.     /**
  71.      * @return mixed
  72.      */
  73.     public function getIsDefault()
  74.     {
  75.         return $this->is_default;
  76.     }
  77.     /**
  78.      * @param mixed $is_default
  79.      */
  80.     public function setIsDefault($is_default): void
  81.     {
  82.         $this->is_default $is_default;
  83.     }
  84.     /**
  85.      * @return mixed
  86.      */
  87.     public function getLanguageCode()
  88.     {
  89.         return $this->language_code;
  90.     }
  91.     /**
  92.      * @param mixed $language_code
  93.      */
  94.     public function setLanguageCode($language_code): void
  95.     {
  96.         $this->language_code $language_code;
  97.     }
  98.     /**
  99.      * @return mixed
  100.      */
  101.     public function getIsoCode()
  102.     {
  103.         return $this->iso_code;
  104.     }
  105.     /**
  106.      * @param mixed $iso_code
  107.      */
  108.     public function setIsoCode($iso_code): void
  109.     {
  110.         $this->iso_code $iso_code;
  111.     }
  112.     /**
  113.      * @return mixed
  114.      */
  115.     public function getDateFormat()
  116.     {
  117.         return $this->date_format;
  118.     }
  119.     /**
  120.      * @param mixed $date_format
  121.      */
  122.     public function setDateFormat($date_format): void
  123.     {
  124.         $this->date_format $date_format;
  125.     }
  126.     /**
  127.      * @return mixed
  128.      */
  129.     public function getDateFormatFull()
  130.     {
  131.         return $this->date_format_full;
  132.     }
  133.     /**
  134.      * @param mixed $date_format_full
  135.      */
  136.     public function setDateFormatFull($date_format_full): void
  137.     {
  138.         $this->date_format_full $date_format_full;
  139.     }
  140.     /**
  141.      * @return string
  142.      */
  143.     public function getImage()
  144.     {
  145.         return $this->image;
  146.     }
  147.     /**
  148.      * @param string $image
  149.      */
  150.     public function setImage(?string $image)
  151.     {
  152.         $this->image $image;
  153.     }
  154.     /**
  155.      * @return File
  156.      */
  157.     public function getImageFile()
  158.     {
  159.         return $this->imageFile;
  160.     }
  161.     /**
  162.      * @param File $imageFile
  163.      * @throws \Exception
  164.      */
  165.     public function setImageFile(File $imageFile)
  166.     {
  167.         $this->imageFile $imageFile;
  168.         if ($imageFile) {
  169.             $this->setUpdatedAt(new \DateTime('now'));
  170.         }
  171.     }
  172.     public function serialize(){
  173.         return [
  174.             'is_default' => $this->getIsDefault(),
  175.             'designation' => $this->getDesignation(),
  176.             'iso_code' => $this->getIsoCode(),
  177.             'language_code' => $this->getLanguageCode(),
  178.             'date_format' => $this->getDateFormat(),
  179.             'date_format_full' => $this->getDateFormatFull(),
  180.         ];
  181.     }
  182. }