<?php
namespace App\Entity;
use App\Business\LocalizableEntity;
use App\Business\NodeContract;
use App\Business\TransmissionOriginInterface;
use App\Application\Sonata\MediaBundle\Entity\Media;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
use JMS\Serializer\Annotation as Serializer;
/**
* Node
*
* @ORM\Table(name="nodes")
* @ORM\Entity(repositoryClass="App\Repository\NodeRepository")
*/
class Node extends LocalizableEntity implements NodeContract, TransmissionOriginInterface
{
use \Gedmo\Timestampable\Traits\TimestampableEntity;
use BlameableEntity;
use SoftDeleteableEntity;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
* @ORM\Column(name="status", type="string", length=20, nullable=true)
*/
private $status;
/**
* @var string
* @ORM\Column(name="node_id", type="string", length=255)
* @Serializer\SerializedName("nodeId")
*/
private $nodeId;
/**
* @var string
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var string
* @ORM\Column(name="city_code", type="string", length=255, nullable=true)
*/
private $cityCode;
/**
* @var string
* @ORM\Column(name="country_code", type="string", length=255, nullable=true)
*/
private $countryCode;
/**
* @var string
* @ORM\Column(name="country_name", type="string", length=255, nullable=true)
*/
private $countryName;
/**
* Concatenation of country + city to easier search
*
* @var string
* @ORM\Column(name="country_city_code", type="string", length=255, nullable=true)
*/
private $countryCityCode;
/**
* @var string
* @ORM\Column(name="city_name", type="string", length=255, nullable=true)
*/
private $cityName;
/**
* @var string
* @ORM\Column(name="organizationId", type="string", length=255, nullable=true)
*/
private $organizationId;
/**
* @var string
* @ORM\Column(name="organizationCode", type="string", length=255, nullable=true)
*/
private $organizationCode;
/**
* @var string
* @ORM\Column(name="organizationName", type="string", length=255, nullable=true)
*/
private $organizationName;
/**
* @var string
* @ORM\Column(name="code", type="string", length=255)
*/
private $code;
/**
* @var string
* @ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* @var string
* @ORM\Column(name="postal_address", type="text", nullable=true)
*/
private $postalAddress;
/**
* @var string
* @ORM\Column(name="lat_lng", type="string", nullable=true)
*/
private $latLng;
/**
* @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"}, fetch="LAZY")
*/
private $image;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Event", inversedBy="nodes", cascade={"persist"})
* @ORM\JoinColumn(name="event_id", referencedColumnName="id")
*/
private $event;
/**
* FROM NEOS
* @ORM\OneToMany(targetEntity="\App\Entity\EventFacility", mappedBy="eventNode", cascade={"persist","remove"}, orphanRemoval=false)
* @ORM\OrderBy({"text" = "ASC"})
*/
private $facilities;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\EventContact", cascade={"persist"})
* @ORM\JoinTable(name="event_contact_facilities",
* joinColumns={@ORM\JoinColumn(name="facility_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="event_contact_id", referencedColumnName="id")}
* )
*/
private $eventContacts;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Document", cascade={"persist"})
* @ORM\JoinTable(name="document_facilities",
* joinColumns={@ORM\JoinColumn(name="facility_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id")}
* )
*/
private $documents;
/**
* Node constructor.
*/
public function __construct()
{
$this->documents = new ArrayCollection();
$this->facilities = new ArrayCollection();
$this->eventContacts = new ArrayCollection();
}
/**
* @return string
*/
public function getOrganizationId(): ?string
{
return $this->organizationId;
}
/**
* @param string $organizationId
*/
public function setOrganizationId(string $organizationId = null): void
{
$this->organizationId = $organizationId;
}
/**
* @return string
*/
public function getOrganizationCode(): ?string
{
if (empty($this->organizationCode) && $this->getEvent() != null && $this->getEvent()->getEventGroupContactsHost() != null) {
return $this->getEvent()->getEventGroupContactsHost()->getCode();
}
return $this->organizationCode;
}
/**
* @param string $organizationCode
*/
public function setOrganizationCode(string $organizationCode = null): void
{
$this->organizationCode = $organizationCode;
}
/**
* Get event
*
* @return Event
*/
public function getEvent()
{
return $this->event;
}
/**
* Set event
*
* @param Event $event
*
* @return Node
*/
public function setEvent(Event $event = null)
{
$this->event = $event;
return $this;
}
/**
* @return string
*/
public function getOrganizationName(): ?string
{
if (empty($this->organizationName) && $this->getEvent() != null && $this->getEvent()->getEventGroupContactsHost() != null) {
return $this->getEvent()->getEventGroupContactsHost()->getName();
}
return $this->organizationName;
}
/**
* @param string $organizationName
*/
public function setOrganizationName(?string $organizationName): void
{
$this->organizationName = $organizationName;
}
/**
* @return string
*/
public function getStatus(): ?string
{
return $this->status;
}
/**
* @param string $status
*/
public function setStatus(string $status): void
{
$this->status = $status;
}
/**
* @return mixed
*/
public function getCountryCityCode()
{
return $this->countryCityCode;
}
public function updateCountryCityCode()
{
$this->countryCityCode = Location::buildCountryCityCode($this->getCountryCode(), $this->getCityCode());
}
/**
* @return string
*/
public function getCountryCode(): ?string
{
return $this->countryCode;
}
/**
* @param string $countryCode
*/
public function setCountryCode(string $countryCode = null)
{
$this->countryCode = $countryCode;
}
/**
* @return string
*/
public function getCityCode(): ?string
{
return $this->cityCode;
}
/**
* @param string $cityCode
*/
public function setCityCode(string $cityCode = null)
{
$this->cityCode = $cityCode;
}
/**
* Add contact
*
*
* @param EventContact $eventContact
* @return Node
*/
public function addEventContact(EventContact $eventContact)
{
$this->eventContacts->add($eventContact);
return $this;
}
/**
* Remove contact
*
* @param EventContact $eventContact
*/
public function removeEventContact(EventContact $eventContact)
{
$this->eventContacts->removeElement($eventContact);
}
/**
* @return mixed
*/
public function getEventContacts()
{
return $this->eventContacts;
}
/**
* Add document
*
*
* @param Document $document
* @return Node
*/
public function addDocument(Document $document)
{
$this->documents->add($document);
return $this;
}
/**
* Remove document
*
* @param Document $document
*/
public function removeDocument(Document $document)
{
$this->documents->removeElement($document);
}
/**
* @return mixed
*/
public function getDocuments()
{
return $this->documents;
}
/**
* @return mixed
*/
public function getCountryName()
{
return $this->countryName;
}
/**
* @param mixed $countryName
*/
public function setCountryName($countryName)
{
$this->countryName = $countryName;
}
/**
* @return string
*/
public function getCode(): string
{
return $this->code;
}
/**
* @param string $code
*/
public function setCode(string $code)
{
$this->code = $code;
}
/**
* Add facility
*
*
* @param EventFacility $facility
* @return Node
*/
public function addFacility(EventFacility $facility)
{
$facility->setEventNode($this);
$this->facilities[] = $facility;
return $this;
}
/**
* Remove facility
*
* @param EventFacility $facility
*/
public function removeFacility(EventFacility $facility)
{
$this->facilities->removeElement($facility);
}
public function getFacilitiesAsArray()
{
if ($this->getFacilities() == null) {
return [];
}
return $this->getFacilities()->getValues();
}
/**
* Get facilities
*
* @return Collection
*/
public function getFacilities()
{
return $this->facilities;
}
/**
* @return string
*/
public function getCityName(): ?string
{
return $this->cityName;
}
/**
* @param string $cityName
*/
public function setCityName(string $cityName = null)
{
$this->cityName = $cityName;
}
public function toString(): string
{
return "{id=" . $this->id . "}";
}
public function __toString()
{
return (string)$this->title;
}
public function uploadImage()
{
}
/**
* Get image
*
* @return Media
*/
public function getImage(): ?Media
{
return $this->image;
}
/**
* Set image
*
* @param Media $image
*
* @return Node
*/
public function setImage(Media $image = null)
{
$this->image = $image;
return $this;
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* Get nodeId
*
* @return string
*/
public function getNodeId()
{
return $this->nodeId;
}
/**
* Set nodeId
*
* @param string $nodeId
*
* @return Node
*/
public function setNodeId($nodeId)
{
$this->nodeId = $nodeId;
return $this;
}
/**
* @return string the title
*/
public function getName()
{
return $this->getTitle();
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set title
*
* @param string $title
*
* @return Node
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set description
*
* @param string $description
*
* @return Node
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get postalAdress
*
* @return string
*/
public function getPostalAddress()
{
return $this->postalAddress;
}
/**
* Set postalAdress
*
* @param string $postalAddress
*
* @return Node
*/
public function setPostalAddress($postalAddress)
{
$this->postalAddress = $postalAddress;
return $this;
}
/**
* Get longLat
*
* @return string
*/
public function getLatLng()
{
return $this->latLng;
}
/**
* Set longLat
*
* @param string $latLng
*
* @return Node
*/
public function setLatLng($latLng)
{
$this->latLng = $latLng;
return $this;
}
}