src/Entity/Banner/AbstractBannerBase.php line 205

Open in your IDE?
  1. <?php
  2. namespace Slivki\Entity\Banner;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Slivki\Entity\City;
  6. use Slivki\Entity\Entity;
  7. use function array_map;
  8. abstract class AbstractBannerBase extends Entity implements \JsonSerializable {
  9.     const TYPE NULL;
  10.     protected $typeID;
  11.     protected $title;
  12.     protected $URL;
  13.     protected $filePath;
  14.     protected $filePathMobile;
  15.     protected $substitutePath;
  16.     protected $active;
  17.     protected $javaScript;
  18.     protected $json;
  19.     protected $code;
  20.     protected $codeFilePath;
  21.     protected $position;
  22.     private ?string $pixelCode;
  23.     private ?string $pixelCodeMobile;
  24.     protected ?Collection $cities;
  25.     protected $cityID;
  26.     protected $cityIds;
  27.     public function __construct()
  28.     {
  29.         $this->cities = new ArrayCollection();
  30.     }
  31.     public function getTypeID() {
  32.         return $this->typeID;
  33.     }
  34.     public function setTypeID($typeID) {
  35.         $this->typeID $typeID;
  36.     }
  37.     public function getTitle() {
  38.         return $this->title;
  39.     }
  40.     public function getMailingURL() {
  41.         return $this->URL explode("?"$this->URL)[0] : '';
  42.     }
  43.     public function setTitle($title) {
  44.         $this->title $title;
  45.     }
  46.     public function getURL() {
  47.         return $this->URL;
  48.     }
  49.     public function setURL($URL) {
  50.         $this->URL $URL;
  51.     }
  52.     public function getFilePath() {
  53.         return $this->filePath;
  54.     }
  55.     public function setFilePath($filePath) {
  56.         $this->filePath $filePath;
  57.     }
  58.     public function getFilePathMobile() {
  59.         return $this->filePathMobile;
  60.     }
  61.     public function setFilePathMobile($filePathMobile) {
  62.         $this->filePathMobile $filePathMobile;
  63.     }
  64.     public function getSubstitutePath() {
  65.         return $this->substitutePath;
  66.     }
  67.     public function setSubstitutePath($substitutePath) {
  68.         $this->substitutePath $substitutePath;
  69.     }
  70.     public function isActive() {
  71.         return $this->active;
  72.     }
  73.     public function setActive($active) {
  74.         $this->active $active;
  75.     }
  76.     public function isJavaScript() {
  77.         return $this->javaScript;
  78.     }
  79.     public function setJavaScript($javaScript) {
  80.         $this->javaScript $javaScript;
  81.     }
  82.     public function isJson() {
  83.         return $this->json;
  84.     }
  85.     public function setJson($json) {
  86.         $this->json $json;
  87.     }
  88.     public function getCode() {
  89.         return $this->code;
  90.     }
  91.     public function setCode($code) {
  92.         $this->code $code;
  93.     }
  94.     public function getCodeFilePath() {
  95.         return $this->codeFilePath;
  96.     }
  97.     public function setCodeFilePath($codeFilePath) {
  98.         $this->codeFilePath $codeFilePath;
  99.     }
  100.     public function getPixelCode(): ?string
  101.     {
  102.         return $this->pixelCode;
  103.     }
  104.     public function setPixelCode(?string $pixelCode): void
  105.     {
  106.         $this->pixelCode $pixelCode;
  107.     }
  108.     public function getPixelCodeMobile(): ?string
  109.     {
  110.         return $this->pixelCodeMobile;
  111.     }
  112.     public function setPixelCodeMobile(?string $pixelCodeMobile): void
  113.     {
  114.         $this->pixelCodeMobile $pixelCodeMobile;
  115.     }
  116.     public function jsonSerialize(): array
  117.     {
  118.         return [
  119.             'ID' => $this->ID,
  120.             'title' => $this->title,
  121.             'url' => $this->URL,
  122.             'filePath' => $this->filePath,
  123.             'active' => $this->active,
  124.             'pixelCode' => $this->pixelCode,
  125.             'pixelCodeMobile' => $this->pixelCodeMobile,
  126.             'cityIds' => $this->getCityIds(),
  127.         ];
  128.     }
  129.     public function getPosition() {
  130.         return $this->position;
  131.     }
  132.     public function setPosition($position) {
  133.         $this->position $position;
  134.     }
  135.     public function editPosition(int $position): void
  136.     {
  137.         $this->position $position;
  138.     }
  139.     public function activate(): void
  140.     {
  141.         $this->active true;
  142.     }
  143.     public function deactivate(): void
  144.     {
  145.         $this->active false;
  146.     }
  147.     public function addCity(City $city): void
  148.     {
  149.         if (!$this->cities->contains($city)) {
  150.             $this->cities->add($city);
  151.         }
  152.     }
  153.     public function removeCities(): void
  154.     {
  155.         $this->cities->clear();
  156.     }
  157.     public function getCityIds(): array
  158.     {
  159.         return array_map(
  160.             function(City $city) {
  161.                 return $city->getID();
  162.             },
  163.             $this->cities->toArray()
  164.         );
  165.     }
  166. }