<?php
/**
* Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
* See https://www.x-cart.com/license-agreement.html for license details.
*/
namespace QSL\Make\Model;
use ApiPlatform\Core\Annotation as ApiPlatform;
use Doctrine\ORM\Mapping as ORM;
use QSL\Make\API\Endpoint\Level1\DTO\Level1Input as Input;
use QSL\Make\API\Endpoint\Level1\DTO\Level1Output as Output;
/**
* @ORM\Entity (repositoryClass="\QSL\Make\Model\Repo\Level1")
* @ORM\Table (name="level1",
* indexes={
* @ORM\Index (name="enabled", columns={"enabled"}),
* @ORM\Index (name="showOnFrontPage", columns={"showOnFrontPage"})
* }
* )
* @ApiPlatform\ApiResource(
* shortName="Make/Model/Year - Level1",
* input=Input::class,
* output=Output::class,
* itemOperations={
* "get"={
* "method"="GET",
* "path"="/qsl/make/level1/{id}.{_format}",
* "identifiers"={"id"},
* "requirements"={"id"="\d+"}
* },
* "put"={
* "method"="PUT",
* "path"="/qsl/make/level1/{id}.{_format}",
* "identifiers"={"id"},
* "requirements"={"id"="\d+"}
* },
* "delete"={
* "method"="DELETE",
* "path"="/qsl/make/level1/{id}.{_format}",
* "identifiers"={"id"},
* "requirements"={"id"="\d+"}
* }
* },
* collectionOperations={
* "get"={
* "method"="GET",
* "path"="/qsl/make/level1.{_format}",
* "identifiers"={}
* },
* "post"={
* "method"="POST",
* "path"="/qsl/make/level1.{_format}",
* "identifiers"={},
* "controller"="xcart.api.qsl.make.level1.controller"
* }
* },
* attributes={
* "pagination_items_per_page" = 100
* }
* )
*/
class Level1 extends ALevel
{
/**
* Level2 list
*
* @var \Doctrine\Common\Collections\ArrayCollection
*
* @ORM\OneToMany (targetEntity="QSL\Make\Model\Level2", mappedBy="level1", cascade={"all"})
* @ORM\OrderBy ({"value" = "ASC"})
*/
protected $level2;
/**
* Banner images
*
* @var \Doctrine\Common\Collections\ArrayCollection
*
* @ORM\OneToMany (targetEntity="QSL\Make\Model\Image\Level1", mappedBy="level", cascade={"all"})
*/
protected $images;
/**
* @var \QSL\Make\Model\Image\Level1Logo
*
* @ORM\OneToOne (targetEntity="QSL\Make\Model\Image\Level1Logo", mappedBy="level", cascade={"all"})
*/
protected $logo;
/**
* Clean URLs
*
* @var \Doctrine\Common\Collections\ArrayCollection
*
* @ORM\OneToMany (targetEntity="XLite\Model\CleanURL", mappedBy="level1", cascade={"all"})
* @ORM\OrderBy ({"id" = "ASC"})
*/
protected $cleanURLs;
/**
* @var \Doctrine\Common\Collections\Collection
*
* @ORM\OneToMany (targetEntity="QSL\Make\Model\Level1Translation", mappedBy="owner", cascade={"all"})
*/
protected $translations;
/**
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getCleanURLs()
{
return $this->cleanURLs;
}
/**
* @@param \Doctrine\Common\Collections\ArrayCollection
*/
public function setCleanURLs($value)
{
$this->cleanURLs = $value;
}
/**
* Add cleanURL
*
* @param \XLite\Model\CleanURL $cleanURL
*/
public function addCleanURLs(\XLite\Model\CleanURL $cleanURL)
{
$this->cleanURLs[] = $cleanURL;
}
/**
* @param \Doctrine\Common\Collections\ArrayCollection $value
*
* @return $this
*/
public function setImages($value)
{
$this->images = $value;
return $this;
}
/**
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getImages()
{
return $this->images;
}
/**
* @return string
*/
/**
* @return \QSL\Make\Model\Image\Level1Logo
*/
public function getLogo()
{
return $this->logo;
}
/**
* @param \QSL\Make\Model\Image\Level1Logo $value
*/
public function setLogo($value)
{
$this->logo = $value;
}
/**
* @return string
*/
public function getCustomerTitle()
{
return $this->getTitle();
}
/**
* @return string
*/
public function getCustomerValue()
{
return $this->getValue();
}
/**
* @return string
*/
public function getDisplayDescription()
{
return $this->getDescription();
}
/**
* @return Image\Level1
*/
public function getCustomerImage()
{
return $this->getImages();
}
/**
* @return \Doctrine\Common\Collections\ArrayCollection
*/
public function getLevel2()
{
return $this->level2;
}
/**
* @param mixed $value
*
* @return \QSL\Make\Model\Level1
*/
public function addLevel2($value)
{
$this->level2[] = $value;
return $this;
}
/**
* @return string
*/
public function getLevelName($delimiter = ' ')
{
return $this->getValue();
}
public function getPathData(): array
{
return [['id' => $this->getId(), 'name' => $this->getValue()]];
}
/**
* @return array
*/
public function getLevelSelectors()
{
return [
\XLite\Core\Config::getInstance()->QSL->Make->level1name => [
'id' => $this->getId(),
'value' => $this->getValue()
]
];
}
/**
* Constructor
*
* @param array $data Entity properties OPTIONAL
*/
public function __construct(array $data = [])
{
$this->level2 = new \Doctrine\Common\Collections\ArrayCollection();
$this->cleanURLs = new \Doctrine\Common\Collections\ArrayCollection();
$this->images = new \Doctrine\Common\Collections\ArrayCollection();
parent::__construct($data);
}
public function getLevelPath()
{
return $this->getValue();
}
/**
* @return null
*/
public function getParentLevel()
{
return null;
}
public function getDepth(): int
{
return 1;
}
}