classes/XLite/Model/Image/Category/Banner.php line 96

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\Image\Category;
  7. use ApiPlatform\Core\Annotation as ApiPlatform;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use XLite\API\Endpoint\CategoryBanner\DTO\CategoryBannerInput;
  10. use XLite\API\Endpoint\CategoryBanner\DTO\CategoryBannerOutput;
  11. use XLite\Controller\API\CategoryBanner\DeleteCategoryBanner;
  12. /**
  13.  * Category
  14.  *
  15.  * @ORM\Entity
  16.  * @ORM\Table  (name="category_banners")
  17.  * @ApiPlatform\ApiResource(
  18.  *     shortName="Category Banner",
  19.  *     output=CategoryBannerOutput::class,
  20.  *     itemOperations={
  21.  *         "get"={
  22.  *             "method"="GET",
  23.  *             "path"="/categories/{category_id}/banner.{_format}",
  24.  *             "identifiers"={"category_id"},
  25.  *             "requirements"={"category_id"="\d+"},
  26.  *             "openapi_context"={
  27.  *                  "summary"="Retrieve a banner from a category",
  28.  *                  "parameters"={
  29.  *                      {"name"="category_id", "in"="path", "required"=true, "schema"={"type"="integer"}}
  30.  *                  }
  31.  *             },
  32.  *          },
  33.  *         "delete"={
  34.  *             "method"="DELETE",
  35.  *             "path"="/categories/{category_id}/banner.{_format}",
  36.  *             "identifiers"={"category_id"},
  37.  *             "requirements"={"category_id"="\d+"},
  38.  *             "controller"=DeleteCategoryBanner::class,
  39.  *             "read"=false,
  40.  *             "openapi_context"={
  41.  *                  "summary"="Delete a banner from a category",
  42.  *                  "parameters"={
  43.  *                      {"name"="category_id", "in"="path", "required"=true, "schema"={"type"="integer"}}
  44.  *                  }
  45.  *             },
  46.  *         },
  47.  *     },
  48.  *     collectionOperations={
  49.  *         "post"={
  50.  *             "method"="POST",
  51.  *             "input"=CategoryBannerInput::class,
  52.  *             "path"="/categories/{category_id}/banner.{_format}",
  53.  *             "identifiers"={"category_id"},
  54.  *             "requirements"={"category_id"="\d+"},
  55.  *             "openapi_context"={
  56.  *                 "summary"="Add a banner to a category",
  57.  *                 "parameters"={
  58.  *                     {"name"="category_id", "in"="path", "required"=true, "schema"={"type"="integer"}}
  59.  *                 },
  60.  *                 "requestBody"={
  61.  *                     "content"={
  62.  *                         "application/json"={
  63.  *                             "schema"={
  64.  *                                 "type"="object",
  65.  *                                 "properties"={
  66.  *                                     "alt"={
  67.  *                                         "type"="string",
  68.  *                                         "description"="Alt text"
  69.  *                                     },
  70.  *                                     "externalUrl"={
  71.  *                                         "type"="string",
  72.  *                                         "description"="URL to the image file which will be downloaded from there"
  73.  *                                     },
  74.  *                                     "attachment"={
  75.  *                                         "type"="string",
  76.  *                                         "description"="base64-encoded image"
  77.  *                                     },
  78.  *                                     "filename"={
  79.  *                                         "type"="string",
  80.  *                                         "description"="Image name with correct extension. Required for 'attachement' field."
  81.  *                                     },
  82.  *                                 },
  83.  *                             },
  84.  *                         },
  85.  *                     },
  86.  *                 },
  87.  *             },
  88.  *         }
  89.  *     }
  90.  * )
  91.  */
  92. class Banner extends \XLite\Model\Base\Image
  93. {
  94.     /**
  95.      * Relation to a category entity
  96.      *
  97.      * @var \XLite\Model\Category
  98.      *
  99.      * @ORM\OneToOne   (targetEntity="XLite\Model\Category", inversedBy="banner")
  100.      * @ORM\JoinColumn (name="category_id", referencedColumnName="category_id", onDelete="CASCADE")
  101.      */
  102.     protected $category;
  103.     /**
  104.      * Alternative image text
  105.      *
  106.      * @var string
  107.      *
  108.      * @ORM\Column (type="string", length=255)
  109.      */
  110.     protected $alt '';
  111.     /**
  112.      * Set alt
  113.      *
  114.      * @param string $alt
  115.      * @return Image
  116.      */
  117.     public function setAlt($alt)
  118.     {
  119.         $this->alt $alt;
  120.         return $this;
  121.     }
  122.     /**
  123.      * Get alt
  124.      *
  125.      * @return string
  126.      */
  127.     public function getAlt()
  128.     {
  129.         return $this->alt;
  130.     }
  131.     /**
  132.      * Set category
  133.      *
  134.      * @param \XLite\Model\Category $category
  135.      * @return Image
  136.      */
  137.     public function setCategory(\XLite\Model\Category $category null)
  138.     {
  139.         $this->category $category;
  140.         return $this;
  141.     }
  142.     /**
  143.      * Get category
  144.      *
  145.      * @return \XLite\Model\Category
  146.      */
  147.     public function getCategory()
  148.     {
  149.         return $this->category;
  150.     }
  151. }