modules/QSL/Make/src/Model/Level1.php line 65

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 QSL\Make\Model;
  7. use ApiPlatform\Core\Annotation as ApiPlatform;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use QSL\Make\API\Endpoint\Level1\DTO\Level1Input as Input;
  10. use QSL\Make\API\Endpoint\Level1\DTO\Level1Output as Output;
  11. /**
  12.  * @ORM\Entity (repositoryClass="\QSL\Make\Model\Repo\Level1")
  13.  * @ORM\Table  (name="level1",
  14.  *      indexes={
  15.  *          @ORM\Index (name="enabled", columns={"enabled"}),
  16.  *          @ORM\Index (name="showOnFrontPage", columns={"showOnFrontPage"})
  17.  *      }
  18.  * )
  19.  * @ApiPlatform\ApiResource(
  20.  *     shortName="Make/Model/Year - Level1",
  21.  *     input=Input::class,
  22.  *     output=Output::class,
  23.  *     itemOperations={
  24.  *          "get"={
  25.  *              "method"="GET",
  26.  *              "path"="/qsl/make/level1/{id}.{_format}",
  27.  *              "identifiers"={"id"},
  28.  *              "requirements"={"id"="\d+"}
  29.  *          },
  30.  *          "put"={
  31.  *              "method"="PUT",
  32.  *              "path"="/qsl/make/level1/{id}.{_format}",
  33.  *              "identifiers"={"id"},
  34.  *              "requirements"={"id"="\d+"}
  35.  *          },
  36.  *          "delete"={
  37.  *              "method"="DELETE",
  38.  *              "path"="/qsl/make/level1/{id}.{_format}",
  39.  *              "identifiers"={"id"},
  40.  *              "requirements"={"id"="\d+"}
  41.  *          }
  42.  *     },
  43.  *     collectionOperations={
  44.  *          "get"={
  45.  *              "method"="GET",
  46.  *              "path"="/qsl/make/level1.{_format}",
  47.  *              "identifiers"={}
  48.  *          },
  49.  *          "post"={
  50.  *              "method"="POST",
  51.  *              "path"="/qsl/make/level1.{_format}",
  52.  *              "identifiers"={},
  53.  *              "controller"="xcart.api.qsl.make.level1.controller"
  54.  *          }
  55.  *     },
  56.  *     attributes={
  57.  *         "pagination_items_per_page" = 100
  58.  *     }
  59.  * )
  60.  */
  61. class Level1 extends ALevel
  62. {
  63.     /**
  64.      * Level2 list
  65.      *
  66.      * @var \Doctrine\Common\Collections\ArrayCollection
  67.      *
  68.      * @ORM\OneToMany (targetEntity="QSL\Make\Model\Level2", mappedBy="level1", cascade={"all"})
  69.      * @ORM\OrderBy   ({"value" = "ASC"})
  70.      */
  71.     protected $level2;
  72.     /**
  73.      * Banner images
  74.      *
  75.      * @var \Doctrine\Common\Collections\ArrayCollection
  76.      *
  77.      * @ORM\OneToMany  (targetEntity="QSL\Make\Model\Image\Level1", mappedBy="level", cascade={"all"})
  78.      */
  79.     protected $images;
  80.     /**
  81.      * @var \QSL\Make\Model\Image\Level1Logo
  82.      *
  83.      * @ORM\OneToOne  (targetEntity="QSL\Make\Model\Image\Level1Logo", mappedBy="level", cascade={"all"})
  84.      */
  85.     protected $logo;
  86.     /**
  87.      * Clean URLs
  88.      *
  89.      * @var \Doctrine\Common\Collections\ArrayCollection
  90.      *
  91.      * @ORM\OneToMany (targetEntity="XLite\Model\CleanURL", mappedBy="level1", cascade={"all"})
  92.      * @ORM\OrderBy   ({"id" = "ASC"})
  93.      */
  94.     protected $cleanURLs;
  95.     /**
  96.      * @var \Doctrine\Common\Collections\Collection
  97.      *
  98.      * @ORM\OneToMany (targetEntity="QSL\Make\Model\Level1Translation", mappedBy="owner", cascade={"all"})
  99.      */
  100.     protected $translations;
  101.     /**
  102.      * @return \Doctrine\Common\Collections\ArrayCollection
  103.      */
  104.     public function getCleanURLs()
  105.     {
  106.         return $this->cleanURLs;
  107.     }
  108.     /**
  109.      * @@param \Doctrine\Common\Collections\ArrayCollection
  110.      */
  111.     public function setCleanURLs($value)
  112.     {
  113.         $this->cleanURLs $value;
  114.     }
  115.     /**
  116.      * Add cleanURL
  117.      *
  118.      * @param \XLite\Model\CleanURL $cleanURL
  119.      */
  120.     public function addCleanURLs(\XLite\Model\CleanURL $cleanURL)
  121.     {
  122.         $this->cleanURLs[] = $cleanURL;
  123.     }
  124.     /**
  125.      * @param \Doctrine\Common\Collections\ArrayCollection $value
  126.      *
  127.      * @return $this
  128.      */
  129.     public function setImages($value)
  130.     {
  131.         $this->images $value;
  132.         return $this;
  133.     }
  134.     /**
  135.      * @return \Doctrine\Common\Collections\ArrayCollection
  136.      */
  137.     public function getImages()
  138.     {
  139.         return $this->images;
  140.     }
  141.     /**
  142.      * @return string
  143.      */
  144.     /**
  145.      * @return \QSL\Make\Model\Image\Level1Logo
  146.      */
  147.     public function getLogo()
  148.     {
  149.         return $this->logo;
  150.     }
  151.     /**
  152.      * @param \QSL\Make\Model\Image\Level1Logo $value
  153.      */
  154.     public function setLogo($value)
  155.     {
  156.         $this->logo $value;
  157.     }
  158.     /**
  159.      * @return string
  160.      */
  161.     public function getCustomerTitle()
  162.     {
  163.         return $this->getTitle();
  164.     }
  165.     /**
  166.      * @return string
  167.      */
  168.     public function getCustomerValue()
  169.     {
  170.         return $this->getValue();
  171.     }
  172.     /**
  173.      * @return string
  174.      */
  175.     public function getDisplayDescription()
  176.     {
  177.         return $this->getDescription();
  178.     }
  179.     /**
  180.      * @return Image\Level1
  181.      */
  182.     public function getCustomerImage()
  183.     {
  184.         return $this->getImages();
  185.     }
  186.     /**
  187.      * @return \Doctrine\Common\Collections\ArrayCollection
  188.      */
  189.     public function getLevel2()
  190.     {
  191.         return $this->level2;
  192.     }
  193.     /**
  194.      * @param mixed $value
  195.      *
  196.      * @return \QSL\Make\Model\Level1
  197.      */
  198.     public function addLevel2($value)
  199.     {
  200.         $this->level2[] = $value;
  201.         return $this;
  202.     }
  203.     /**
  204.      * @return string
  205.      */
  206.     public function getLevelName($delimiter ' ')
  207.     {
  208.         return $this->getValue();
  209.     }
  210.     public function getPathData(): array
  211.     {
  212.         return [['id' => $this->getId(), 'name' => $this->getValue()]];
  213.     }
  214.     /**
  215.      * @return array
  216.      */
  217.     public function getLevelSelectors()
  218.     {
  219.         return [
  220.             \XLite\Core\Config::getInstance()->QSL->Make->level1name => [
  221.                 'id' => $this->getId(),
  222.                 'value' => $this->getValue()
  223.             ]
  224.         ];
  225.     }
  226.     /**
  227.      * Constructor
  228.      *
  229.      * @param array $data Entity properties OPTIONAL
  230.      */
  231.     public function __construct(array $data = [])
  232.     {
  233.         $this->level2    = new \Doctrine\Common\Collections\ArrayCollection();
  234.         $this->cleanURLs = new \Doctrine\Common\Collections\ArrayCollection();
  235.         $this->images = new \Doctrine\Common\Collections\ArrayCollection();
  236.         parent::__construct($data);
  237.     }
  238.     public function getLevelPath()
  239.     {
  240.         return $this->getValue();
  241.     }
  242.     /**
  243.      * @return null
  244.      */
  245.     public function getParentLevel()
  246.     {
  247.         return  null;
  248.     }
  249.     public function getDepth(): int
  250.     {
  251.         return 1;
  252.     }
  253. }