classes/XLite/Model/CleanURL.php line 17

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.  * CleanURL
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table (name="clean_urls",
  13.  *      indexes={
  14.  *          @ORM\Index (name="cleanURL", columns={"cleanURL"}),
  15.  *          @ORM\Index (name="categoryUrls", columns={"cleanURL", "category_id"}),
  16.  *          @ORM\Index (name="productUrls", columns={"cleanURL", "product_id"})
  17.  *      }
  18.  * )
  19.  */
  20. class CleanURL extends \XLite\Model\AEntity
  21. {
  22.     /**
  23.      * Unique id
  24.      *
  25.      * @var integer
  26.      *
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue (strategy="AUTO")
  29.      * @ORM\Column         (type="integer", options={"unsigned": true })
  30.      */
  31.     protected $id;
  32.     /**
  33.      * Relation to a product entity
  34.      *
  35.      * @var \XLite\Model\Product
  36.      *
  37.      * @ORM\ManyToOne  (targetEntity="XLite\Model\Product", inversedBy="cleanURLs")
  38.      * @ORM\JoinColumn (name="product_id", referencedColumnName="product_id", onDelete="CASCADE")
  39.      */
  40.     protected $product;
  41.     /**
  42.      * Relation to a category entity
  43.      *
  44.      * @var \XLite\Model\Category
  45.      *
  46.      * @ORM\ManyToOne  (targetEntity="XLite\Model\Category", inversedBy="cleanURLs")
  47.      * @ORM\JoinColumn (name="category_id", referencedColumnName="category_id", onDelete="CASCADE")
  48.      */
  49.     protected $category;
  50.     /**
  51.      * Clean URL
  52.      *
  53.      * @var string
  54.      *
  55.      * @ORM\Column (type="string", length=255, nullable=true)
  56.      */
  57.     protected $cleanURL;
  58.     /**
  59.      * Set entity
  60.      *
  61.      * @param \XLite\Model\AEntity $entity Entity
  62.      *
  63.      * @return void
  64.      */
  65.     public function setEntity($entity)
  66.     {
  67.         $entityType \XLite\Model\Repo\CleanURL::getEntityType($entity);
  68.         $method 'set' \Includes\Utils\Converter::convertToUpperCamelCase($entityType);
  69.         if (method_exists($this$method)) {
  70.             $this->{$method}($entity);
  71.         }
  72.     }
  73.     /**
  74.      * Get entity
  75.      *
  76.      * @return \XLite\Model\AEntity
  77.      */
  78.     public function getEntity()
  79.     {
  80.         $entity null;
  81.         foreach (\XLite\Model\Repo\CleanURL::getEntityTypes() as $type) {
  82.             $method 'get' \Includes\Utils\Converter::convertToUpperCamelCase($type);
  83.             if (method_exists($this$method)) {
  84.                 $entity $this->{$method}();
  85.                 if ($entity) {
  86.                     break;
  87.                 }
  88.             }
  89.         }
  90.         return $entity;
  91.     }
  92.     /**
  93.      * Get id
  94.      *
  95.      * @return integer
  96.      */
  97.     public function getId()
  98.     {
  99.         return $this->id;
  100.     }
  101.     /**
  102.      * Set cleanURL
  103.      *
  104.      * @param string $cleanURL
  105.      * @return CleanURL
  106.      */
  107.     public function setCleanURL($cleanURL)
  108.     {
  109.         $this->cleanURL $cleanURL;
  110.         return $this;
  111.     }
  112.     /**
  113.      * Get cleanURL
  114.      *
  115.      * @return string
  116.      */
  117.     public function getCleanURL()
  118.     {
  119.         return $this->cleanURL;
  120.     }
  121.     /**
  122.      * Set product
  123.      *
  124.      * @param \XLite\Model\Product $product
  125.      * @return CleanURL
  126.      */
  127.     public function setProduct(\XLite\Model\Product $product null)
  128.     {
  129.         $this->product $product;
  130.         return $this;
  131.     }
  132.     /**
  133.      * Get product
  134.      *
  135.      * @return \XLite\Model\Product
  136.      */
  137.     public function getProduct()
  138.     {
  139.         return $this->product;
  140.     }
  141.     /**
  142.      * Set category
  143.      *
  144.      * @param \XLite\Model\Category $category
  145.      * @return CleanURL
  146.      */
  147.     public function setCategory(\XLite\Model\Category $category null)
  148.     {
  149.         $this->category $category;
  150.         return $this;
  151.     }
  152.     /**
  153.      * Get category
  154.      *
  155.      * @return \XLite\Model\Category
  156.      */
  157.     public function getCategory()
  158.     {
  159.         return $this->category;
  160.     }
  161. }