classes/XLite/Model/LanguageLabel.php line 22

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
  4.  * See https://www.x-cart.com/license-agreement.html for license details.
  5.  */
  6. namespace XLite\Model;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Language label
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table (name="language_labels",
  13.  *      uniqueConstraints={
  14.  *          @ORM\UniqueConstraint (name="name", columns={"name"})
  15.  *      }
  16.  * )
  17.  */
  18. class LanguageLabel extends \XLite\Model\Base\I18n
  19. {
  20.     /**
  21.      * Unique id
  22.      *
  23.      * @var integer
  24.      *
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue (strategy="AUTO")
  27.      * @ORM\Column (type="integer")
  28.      */
  29.     protected $label_id;
  30.     /**
  31.      * Label name
  32.      *
  33.      * @var string
  34.      *
  35.      * @ORM\Column (type="string", length=255, options={"collation":"utf8mb4_bin"})
  36.      */
  37.     protected $name;
  38.     /**
  39.      * @var \Doctrine\Common\Collections\Collection
  40.      *
  41.      * @ORM\OneToMany (targetEntity="XLite\Model\LanguageLabelTranslation", mappedBy="owner", cascade={"all"})
  42.      */
  43.     protected $translations;
  44.     /**
  45.      * Get label translation
  46.      *
  47.      * @param string $code Language code OPTIONAL
  48.      *
  49.      * @return \XLite\Model\LanguageLabelTranslation
  50.      */
  51.     public function getLabelTranslation($code null)
  52.     {
  53.         $result null;
  54.         $query \XLite\Core\Translation::getLanguageQuery($code);
  55.         foreach ($query as $code) {
  56.             $result $this->getTranslation($codetrue);
  57.             if (isset($result) || $code == 'en') {
  58.                 break;
  59.             }
  60.         }
  61.         return $result;
  62.     }
  63.     /**
  64.      * Get label_id
  65.      *
  66.      * @return integer
  67.      */
  68.     public function getLabelId()
  69.     {
  70.         return $this->label_id;
  71.     }
  72.     /**
  73.      * Set name
  74.      *
  75.      * @param string $name
  76.      * @return LanguageLabel
  77.      */
  78.     public function setName($name)
  79.     {
  80.         $this->name $name;
  81.         return $this;
  82.     }
  83.     /**
  84.      * Get name
  85.      *
  86.      * @return string
  87.      */
  88.     public function getName()
  89.     {
  90.         return $this->name;
  91.     }
  92.     /**
  93.      * @param string $label
  94.      *
  95.      * @return void
  96.      */
  97.     public function setLabel($label)
  98.     {
  99.         $this->setTranslationField(__FUNCTION__$label);
  100.     }
  101. }