classes/XLite/Model/ZoneElement.php line 23

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.  * ZoneElement model
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table (name="zone_elements",
  13.  *      indexes={
  14.  *          @ORM\Index (name="type_value", columns={"element_type","element_value"}),
  15.  *          @ORM\Index (name="id_type", columns={"zone_id","element_type"})
  16.  *      }
  17.  * )
  18.  */
  19. class ZoneElement extends \XLite\Model\AEntity
  20. {
  21.     /*
  22.      * Zone element types
  23.      */
  24.     public const ZONE_ELEMENT_COUNTRY 'C';
  25.     public const ZONE_ELEMENT_STATE   'S';
  26.     public const ZONE_ELEMENT_TOWN    'T';
  27.     public const ZONE_ELEMENT_ZIPCODE 'Z';
  28.     public const ZONE_ELEMENT_ADDRESS 'A';
  29.     /**
  30.      * Unique zone element Id
  31.      *
  32.      * @var integer
  33.      *
  34.      * @ORM\Id
  35.      * @ORM\GeneratedValue (strategy="AUTO")
  36.      * @ORM\Column (type="integer", length=11, nullable=false)
  37.      */
  38.     protected $element_id;
  39.     /**
  40.      * Zone element value, e.g. 'US', 'US_NY', 'New Y%' etc
  41.      *
  42.      * @var string
  43.      *
  44.      * @ORM\Column (type="string", length=255)
  45.      */
  46.     protected $element_value;
  47.     /**
  48.      * Element type
  49.      *
  50.      * @var string
  51.      *
  52.      * @ORM\Column (type="string", options={ "fixed": true }, length=1)
  53.      */
  54.     protected $element_type;
  55.     /**
  56.      * Zone (relation)
  57.      *
  58.      * @var \XLite\Model\Zone
  59.      *
  60.      * @ORM\ManyToOne (targetEntity="XLite\Model\Zone", inversedBy="zone_elements")
  61.      * @ORM\JoinColumn (name="zone_id", referencedColumnName="zone_id", onDelete="CASCADE")
  62.      */
  63.     protected $zone;
  64.     /**
  65.      * getElementTypesData
  66.      *
  67.      * @return array
  68.      */
  69.     public static function getElementTypesData()
  70.     {
  71.         return [
  72.             static::ZONE_ELEMENT_COUNTRY => [
  73.                 'field'      => 'country',   // Address field name
  74.                 'weight'     => 0x01,        // Element weight
  75.                 'funcSuffix' => 'Countries'// Suffix for functions name: getZone<Suffix>, checkZone<Suffix>
  76.                 'required'   => true,        // Required property: if true then entire zone declined if this element does bot match
  77.             ],
  78.             static::ZONE_ELEMENT_STATE   => [
  79.                 'field'      => 'state',
  80.                 'weight'     => 0x02,
  81.                 'funcSuffix' => 'States',
  82.                 'required'   => true,
  83.             ],
  84.             static::ZONE_ELEMENT_ZIPCODE => [
  85.                 'field'      => 'zipcode',
  86.                 'weight'     => 0x08,
  87.                 'funcSuffix' => 'ZipCodes',
  88.                 'required'   => true,
  89.             ],
  90.             static::ZONE_ELEMENT_TOWN    => [
  91.                 'field'      => 'city',
  92.                 'weight'     => 0x10,
  93.                 'funcSuffix' => 'Cities',
  94.                 'required'   => true,
  95.             ],
  96.             static::ZONE_ELEMENT_ADDRESS => [
  97.                 'field'      => 'address',
  98.                 'weight'     => 0x20,
  99.                 'funcSuffix' => 'Addresses',
  100.                 'required'   => false,
  101.             ]
  102.         ];
  103.     }
  104.     /**
  105.      * Get element_id
  106.      *
  107.      * @return integer
  108.      */
  109.     public function getElementId()
  110.     {
  111.         return $this->element_id;
  112.     }
  113.     /**
  114.      * Set element_value
  115.      *
  116.      * @param string $elementValue
  117.      * @return ZoneElement
  118.      */
  119.     public function setElementValue($elementValue)
  120.     {
  121.         $this->element_value $elementValue;
  122.         return $this;
  123.     }
  124.     /**
  125.      * Get element_value
  126.      *
  127.      * @return string
  128.      */
  129.     public function getElementValue()
  130.     {
  131.         return $this->element_value;
  132.     }
  133.     /**
  134.      * Set element_type
  135.      *
  136.      * @param string $elementType
  137.      * @return ZoneElement
  138.      */
  139.     public function setElementType($elementType)
  140.     {
  141.         $this->element_type $elementType;
  142.         return $this;
  143.     }
  144.     /**
  145.      * Get element_type
  146.      *
  147.      * @return string
  148.      */
  149.     public function getElementType()
  150.     {
  151.         return $this->element_type;
  152.     }
  153.     /**
  154.      * Set zone
  155.      *
  156.      * @param \XLite\Model\Zone $zone
  157.      * @return ZoneElement
  158.      */
  159.     public function setZone(\XLite\Model\Zone $zone null)
  160.     {
  161.         $this->zone $zone;
  162.         return $this;
  163.     }
  164.     /**
  165.      * Get zone
  166.      *
  167.      * @return \XLite\Model\Zone
  168.      */
  169.     public function getZone()
  170.     {
  171.         return $this->zone;
  172.     }
  173. }