classes/XLite/Model/CleanURL.php line 15

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