classes/XLite/Model/Order/Modifier.php line 18

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\Order;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * Order modifier
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table (name="order_modifiers")
  13.  */
  14. class Modifier extends \XLite\Model\AEntity
  15. {
  16.     /**
  17.      * ID
  18.      *
  19.      * @var integer
  20.      *
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue (strategy="AUTO")
  23.      * @ORM\Column         (type="integer", options={ "unsigned": true })
  24.      */
  25.     protected $id;
  26.     /**
  27.      * Logic class name
  28.      *
  29.      * @var string
  30.      *
  31.      * @ORM\Column (type="string", length=255)
  32.      */
  33.     protected $class;
  34.     /**
  35.      * Weight
  36.      *
  37.      * @var integer
  38.      *
  39.      * @ORM\Column (type="integer")
  40.      */
  41.     protected $weight 0;
  42.     /**
  43.      * Modifier object (cache)
  44.      *
  45.      * @var \XLite\Logic\Order\Modifier\AModifier
  46.      */
  47.     protected $modifier;
  48.     /**
  49.      * Magic call
  50.      *
  51.      * @param string $method Method name
  52.      * @param array  $args   Arguments list OPTIONAL
  53.      *
  54.      * @return mixed
  55.      */
  56.     public function __call($method, array $args = [])
  57.     {
  58.         $modifier $this->getModifier();
  59.         return ($modifier && method_exists($modifier$method))
  60.             ? call_user_func_array([$modifier$method], $args)
  61.             : parent::__call($method$args);
  62.     }
  63.     /**
  64.      * Get modifier object
  65.      *
  66.      * @return \XLite\Logic\Order\Modifier\AModifier
  67.      */
  68.     public function getModifier()
  69.     {
  70.         if (!isset($this->modifier) && class_exists($this->getClass())) {
  71.             $class $this->getClass();
  72.             $this->modifier = new $class($this);
  73.         }
  74.         return $this->modifier;
  75.     }
  76.     /**
  77.      * Get id
  78.      *
  79.      * @return integer
  80.      */
  81.     public function getId()
  82.     {
  83.         return $this->id;
  84.     }
  85.     /**
  86.      * Set class
  87.      *
  88.      * @param string $class
  89.      * @return Modifier
  90.      */
  91.     public function setClass($class)
  92.     {
  93.         $this->class $class;
  94.         return $this;
  95.     }
  96.     /**
  97.      * Get class
  98.      *
  99.      * @return string
  100.      */
  101.     public function getClass()
  102.     {
  103.         return $this->class;
  104.     }
  105.     /**
  106.      * Set weight
  107.      *
  108.      * @param integer $weight
  109.      * @return Modifier
  110.      */
  111.     public function setWeight($weight)
  112.     {
  113.         $this->weight $weight;
  114.         return $this;
  115.     }
  116.     /**
  117.      * Get weight
  118.      *
  119.      * @return integer
  120.      */
  121.     public function getWeight()
  122.     {
  123.         return $this->weight;
  124.     }
  125. }