classes/XLite/Model/AttributeProperty.php line 67

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 ApiPlatform\Core\Annotation as ApiPlatform;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use XLite\API\Endpoint\AttributeProperty\DTO\AttributePropertyInput as Input;
  10. use XLite\API\Endpoint\AttributeProperty\DTO\AttributePropertyOutput as Output;
  11. use XLite\Controller\API\AttributeProperty\Post as PostController;
  12. /**
  13.  * @ORM\Entity
  14.  * @ORM\Table  (name="attribute_properties")
  15.  * @ApiPlatform\ApiResource(
  16.  *     shortName="Attribute Property",
  17.  *     compositeIdentifier=false,
  18.  *     itemOperations={
  19.  *          "get"={
  20.  *              "method"="GET",
  21.  *              "path"="/products/{product_id}/attributes/{attribute_id}/property.{_format}",
  22.  *              "input"=Input::class,
  23.  *              "output"=Output::class,
  24.  *              "requirements"={"product_id"="\d+", "attribute_id"="\d+"},
  25.  *              "identifiers"={"product_id", "attribute_id"},
  26.  *              "openapi_context"={
  27.  *                  "summary"="Retrieve a property from a product attribute",
  28.  *                  "parameters"={
  29.  *                     {"name"="product_id", "in"="path", "required"=true, "schema"={"type"="integer"}},
  30.  *                     {"name"="attribute_id", "in"="path", "required"=true, "schema"={"type"="integer"}},
  31.  *                  }
  32.  *              }
  33.  *          },
  34.  *          "put"={
  35.  *              "method"="PUT",
  36.  *              "path"="/products/{product_id}/attributes/{attribute_id}/property.{_format}",
  37.  *              "input"=Input::class,
  38.  *              "output"=Output::class,
  39.  *              "requirements"={"product_id"="\d+", "attribute_id"="\d+"},
  40.  *              "identifiers"={"product_id", "attribute_id"},
  41.  *              "openapi_context"={
  42.  *                  "summary"="Update a property of a product attribute",
  43.  *                  "parameters"={
  44.  *                     {"name"="product_id", "in"="path", "required"=true, "schema"={"type"="integer"}},
  45.  *                     {"name"="attribute_id", "in"="path", "required"=true, "schema"={"type"="integer"}},
  46.  *                  }
  47.  *              }
  48.  *          }
  49.  *     },
  50.  *     collectionOperations={
  51.  *          "post"={
  52.  *              "method"="POST",
  53.  *              "path"="/products/{product_id}/attributes/{attribute_id}/property.{_format}",
  54.  *              "input"=Input::class,
  55.  *              "output"=Output::class,
  56.  *              "controller"=PostController::class,
  57.  *              "requirements"={"product_id"="\d+", "attribute_id"="\d+"},
  58.  *              "identifiers"={"product_id", "attribute_id"},
  59.  *              "openapi_context"={
  60.  *                  "summary"="Add a property to a product attribute",
  61.  *                  "parameters"={
  62.  *                     {"name"="product_id", "in"="path", "required"=true, "schema"={"type"="integer"}},
  63.  *                     {"name"="attribute_id", "in"="path", "required"=true, "schema"={"type"="integer"}},
  64.  *                  }
  65.  *              }
  66.  *          }
  67.  *     }
  68.  * )
  69.  */
  70. class AttributeProperty extends \XLite\Model\AEntity
  71. {
  72.     /**
  73.      * @var int
  74.      *
  75.      * @ORM\Id
  76.      * @ORM\GeneratedValue (strategy="AUTO")
  77.      * @ORM\Column (type="integer", options={ "unsigned": true })
  78.      */
  79.     protected $id;
  80.     /**
  81.      * @var \XLite\Model\Product
  82.      *
  83.      * @ORM\ManyToOne (targetEntity="XLite\Model\Product")
  84.      * @ORM\JoinColumn (name="product_id", referencedColumnName="product_id", onDelete="CASCADE")
  85.      */
  86.     protected $product;
  87.     /**
  88.      * @var \XLite\Model\Attribute
  89.      *
  90.      * @ORM\ManyToOne (targetEntity="XLite\Model\Attribute", inversedBy="attribute_properties")
  91.      * @ORM\JoinColumn (name="attribute_id", referencedColumnName="id", onDelete="CASCADE")
  92.      */
  93.     protected $attribute;
  94.     /**
  95.      * @var int
  96.      *
  97.      * @ORM\Column (type="integer")
  98.      */
  99.     protected $position 0;
  100.     /**
  101.      * Is attribute shown above the price
  102.      *
  103.      * @var bool
  104.      *
  105.      * @ORM\Column (type="boolean", options={"default":"0"})
  106.      */
  107.     protected $displayAbove false;
  108.     /**
  109.      * @var string
  110.      *
  111.      * @ORM\Column (type="string", options={"fixed": true}, length=1)
  112.      */
  113.     protected $displayMode '';
  114.     /**
  115.      * Get id
  116.      *
  117.      * @return integer
  118.      */
  119.     public function getId()
  120.     {
  121.         return $this->id;
  122.     }
  123.     /**
  124.      * Set position
  125.      *
  126.      * @param integer $position
  127.      * @return AttributeProperty
  128.      */
  129.     public function setPosition($position)
  130.     {
  131.         $this->position $position;
  132.         return $this;
  133.     }
  134.     /**
  135.      * Get position
  136.      *
  137.      * @return integer
  138.      */
  139.     public function getPosition()
  140.     {
  141.         return $this->position;
  142.     }
  143.     /**
  144.      * @param boolean $displayAbove
  145.      * @return AttributeProperty
  146.      */
  147.     public function setDisplayAbove($displayAbove)
  148.     {
  149.         $this->displayAbove $displayAbove;
  150.         return $this;
  151.     }
  152.     /**
  153.      * @return integer
  154.      */
  155.     public function getDisplayAbove()
  156.     {
  157.         return $this->displayAbove;
  158.     }
  159.     /**
  160.      * Set product
  161.      *
  162.      * @param \XLite\Model\Product $product
  163.      * @return AttributeProperty
  164.      */
  165.     public function setProduct(\XLite\Model\Product $product null)
  166.     {
  167.         $this->product $product;
  168.         return $this;
  169.     }
  170.     /**
  171.      * Get product
  172.      *
  173.      * @return \XLite\Model\Product
  174.      */
  175.     public function getProduct()
  176.     {
  177.         return $this->product;
  178.     }
  179.     /**
  180.      * Set attribute
  181.      *
  182.      * @param \XLite\Model\Attribute $attribute
  183.      * @return AttributeProperty
  184.      */
  185.     public function setAttribute(\XLite\Model\Attribute $attribute null)
  186.     {
  187.         $this->attribute $attribute;
  188.         return $this;
  189.     }
  190.     /**
  191.      * Get attribute
  192.      *
  193.      * @return \XLite\Model\Attribute
  194.      */
  195.     public function getAttribute()
  196.     {
  197.         return $this->attribute;
  198.     }
  199.     /**
  200.      * Get display mode
  201.      *
  202.      * @return string
  203.      */
  204.     public function getDisplayMode()
  205.     {
  206.         return $this->displayMode;
  207.     }
  208.     /**
  209.      * Set display mode
  210.      *
  211.      * @return AttributeProperty
  212.      */
  213.     public function setDisplayMode($displayMode)
  214.     {
  215.         $this->displayMode $displayMode;
  216.         return $this;
  217.     }
  218. }