<?php
namespace Slivki\Entity\Banner;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Slivki\Entity\City;
use Slivki\Entity\Entity;
use function array_map;
abstract class AbstractBannerBase extends Entity implements \JsonSerializable {
const TYPE = NULL;
protected $typeID;
protected $title;
protected $URL;
protected $filePath;
protected $filePathMobile;
protected $substitutePath;
protected $active;
protected $javaScript;
protected $json;
protected $code;
protected $codeFilePath;
protected $position;
private ?string $pixelCode;
private ?string $pixelCodeMobile;
protected ?Collection $cities;
protected $cityID;
protected $cityIds;
public function __construct()
{
$this->cities = new ArrayCollection();
}
public function getTypeID() {
return $this->typeID;
}
public function setTypeID($typeID) {
$this->typeID = $typeID;
}
public function getTitle() {
return $this->title;
}
public function getMailingURL() {
return $this->URL ? explode("?", $this->URL)[0] : '';
}
public function setTitle($title) {
$this->title = $title;
}
public function getURL() {
return $this->URL;
}
public function setURL($URL) {
$this->URL = $URL;
}
public function getFilePath() {
return $this->filePath;
}
public function setFilePath($filePath) {
$this->filePath = $filePath;
}
public function getFilePathMobile() {
return $this->filePathMobile;
}
public function setFilePathMobile($filePathMobile) {
$this->filePathMobile = $filePathMobile;
}
public function getSubstitutePath() {
return $this->substitutePath;
}
public function setSubstitutePath($substitutePath) {
$this->substitutePath = $substitutePath;
}
public function isActive() {
return $this->active;
}
public function setActive($active) {
$this->active = $active;
}
public function isJavaScript() {
return $this->javaScript;
}
public function setJavaScript($javaScript) {
$this->javaScript = $javaScript;
}
public function isJson() {
return $this->json;
}
public function setJson($json) {
$this->json = $json;
}
public function getCode() {
return $this->code;
}
public function setCode($code) {
$this->code = $code;
}
public function getCodeFilePath() {
return $this->codeFilePath;
}
public function setCodeFilePath($codeFilePath) {
$this->codeFilePath = $codeFilePath;
}
public function getPixelCode(): ?string
{
return $this->pixelCode;
}
public function setPixelCode(?string $pixelCode): void
{
$this->pixelCode = $pixelCode;
}
public function getPixelCodeMobile(): ?string
{
return $this->pixelCodeMobile;
}
public function setPixelCodeMobile(?string $pixelCodeMobile): void
{
$this->pixelCodeMobile = $pixelCodeMobile;
}
public function jsonSerialize(): array
{
return [
'ID' => $this->ID,
'title' => $this->title,
'url' => $this->URL,
'filePath' => $this->filePath,
'active' => $this->active,
'pixelCode' => $this->pixelCode,
'pixelCodeMobile' => $this->pixelCodeMobile,
'cityIds' => $this->getCityIds(),
];
}
public function getPosition() {
return $this->position;
}
public function setPosition($position) {
$this->position = $position;
}
public function editPosition(int $position): void
{
$this->position = $position;
}
public function activate(): void
{
$this->active = true;
}
public function deactivate(): void
{
$this->active = false;
}
public function addCity(City $city): void
{
if (!$this->cities->contains($city)) {
$this->cities->add($city);
}
}
public function removeCities(): void
{
$this->cities->clear();
}
public function getCityIds(): array
{
return array_map(
function(City $city) {
return $city->getID();
},
$this->cities->toArray()
);
}
}