classes/XLite/Model/ImageSettings.php line 14

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.  * Image settings model
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table  (name="images_settings",
  13.  *      uniqueConstraints={
  14.  *          @ORM\UniqueConstraint (name="code_model_module", columns={"code", "model", "moduleName"})
  15.  *      })
  16.  */
  17. class ImageSettings extends \XLite\Model\AEntity
  18. {
  19.     /**
  20.      * Unique Id
  21.      *
  22.      * @var integer
  23.      *
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue (strategy="AUTO")
  26.      * @ORM\Column         (type="integer")
  27.      */
  28.     protected $id;
  29.     /**
  30.      * Image size code
  31.      *
  32.      * @var string
  33.      *
  34.      * @ORM\Column (type="string", length=64)
  35.      */
  36.     protected $code;
  37.     /**
  38.      * Model (class name of image model)
  39.      *
  40.      * @var string
  41.      *
  42.      * @ORM\Column (type="string", length=200)
  43.      */
  44.     protected $model;
  45.     /**
  46.      * Skin module name - owner of image sizes
  47.      *
  48.      * @var string
  49.      *
  50.      * @ORM\Column (type="string", length=200)
  51.      */
  52.     protected $moduleName;
  53.     /**
  54.      * Image max width
  55.      *
  56.      * @var integer
  57.      *
  58.      * @ORM\Column (type="integer")
  59.      */
  60.     protected $width;
  61.     /**
  62.      * Image max height
  63.      *
  64.      * @var integer
  65.      *
  66.      * @ORM\Column (type="integer")
  67.      */
  68.     protected $height;
  69.     /**
  70.      * Get image setting name
  71.      *
  72.      * @return string
  73.      */
  74.     public function getName()
  75.     {
  76.         return static::t('imgsize-' $this->getImageType() . '-' $this->getCode());
  77.     }
  78.     /**
  79.      * Get image type by model class
  80.      *
  81.      * @return string
  82.      */
  83.     protected function getImageType()
  84.     {
  85.         $imageTypes $this->getImageTypes();
  86.         return !empty($imageTypes[$this->getModel()]) ? $imageTypes[$this->getModel()] : $this->getModel();
  87.     }
  88.     /**
  89.      * Get list of available image size types
  90.      *
  91.      * @return array
  92.      */
  93.     protected function getImageTypes()
  94.     {
  95.         return [
  96.             \XLite\Logic\ImageResize\Generator::MODEL_PRODUCT => 'product',
  97.             \XLite\Logic\ImageResize\Generator::MODEL_CATEGORY => 'category',
  98.         ];
  99.     }
  100.     /**
  101.      * Get id
  102.      *
  103.      * @return integer
  104.      */
  105.     public function getId()
  106.     {
  107.         return $this->id;
  108.     }
  109.     /**
  110.      * Set code
  111.      *
  112.      * @param string $code
  113.      * @return ImageSettings
  114.      */
  115.     public function setCode($code)
  116.     {
  117.         $this->code $code;
  118.         return $this;
  119.     }
  120.     /**
  121.      * Get code
  122.      *
  123.      * @return string
  124.      */
  125.     public function getCode()
  126.     {
  127.         return $this->code;
  128.     }
  129.     /**
  130.      * Set model
  131.      *
  132.      * @param string $model
  133.      * @return ImageSettings
  134.      */
  135.     public function setModel($model)
  136.     {
  137.         $this->model $model;
  138.         return $this;
  139.     }
  140.     /**
  141.      * Get model
  142.      *
  143.      * @return string
  144.      */
  145.     public function getModel()
  146.     {
  147.         return $this->model;
  148.     }
  149.     /**
  150.      * Set width
  151.      *
  152.      * @param integer $width
  153.      * @return ImageSettings
  154.      */
  155.     public function setWidth($width)
  156.     {
  157.         $this->width $width;
  158.         return $this;
  159.     }
  160.     /**
  161.      * Get width
  162.      *
  163.      * @return integer
  164.      */
  165.     public function getWidth()
  166.     {
  167.         return $this->width;
  168.     }
  169.     /**
  170.      * Set height
  171.      *
  172.      * @param integer $height
  173.      * @return ImageSettings
  174.      */
  175.     public function setHeight($height)
  176.     {
  177.         $this->height $height;
  178.         return $this;
  179.     }
  180.     /**
  181.      * Get height
  182.      *
  183.      * @return integer
  184.      */
  185.     public function getHeight()
  186.     {
  187.         return $this->height;
  188.     }
  189.     /**
  190.      * Set module name
  191.      *
  192.      * @param string $moduleName
  193.      * @return ImageSettings
  194.      */
  195.     public function setModuleName($moduleName)
  196.     {
  197.         $this->moduleName $moduleName;
  198.         return $this;
  199.     }
  200.     /**
  201.      * Get module name
  202.      *
  203.      * @return string
  204.      */
  205.     public function getModuleName()
  206.     {
  207.         return $this->moduleName;
  208.     }
  209. }