src/Entity/Node.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Business\LocalizableEntity;
  4. use App\Business\NodeContract;
  5. use App\Business\TransmissionOriginInterface;
  6. use App\Application\Sonata\MediaBundle\Entity\Media;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  11. use JMS\Serializer\Annotation as Serializer;
  12. /**
  13.  * Node
  14.  *
  15.  * @ORM\Table(name="nodes")
  16.  * @ORM\Entity(repositoryClass="App\Repository\NodeRepository")
  17.  */
  18. class Node extends LocalizableEntity implements NodeContractTransmissionOriginInterface
  19. {
  20.     use \Gedmo\Timestampable\Traits\TimestampableEntity;
  21.     use BlameableEntity;
  22.     use SoftDeleteableEntity;
  23.     /**
  24.      * @var int
  25.      *
  26.      * @ORM\Column(name="id", type="integer")
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue(strategy="AUTO")
  29.      */
  30.     private $id;
  31.     /**
  32.      * @var string
  33.      * @ORM\Column(name="status", type="string", length=20, nullable=true)
  34.      */
  35.     private $status;
  36.     /**
  37.      * @var string
  38.      * @ORM\Column(name="node_id", type="string", length=255)
  39.      * @Serializer\SerializedName("nodeId")
  40.      */
  41.     private $nodeId;
  42.     /**
  43.      * @var string
  44.      * @ORM\Column(name="title", type="string", length=255)
  45.      */
  46.     private $title;
  47.     /**
  48.      * @var string
  49.      * @ORM\Column(name="city_code", type="string", length=255, nullable=true)
  50.      */
  51.     private $cityCode;
  52.     /**
  53.      * @var string
  54.      * @ORM\Column(name="country_code", type="string", length=255, nullable=true)
  55.      */
  56.     private $countryCode;
  57.     /**
  58.      * @var string
  59.      * @ORM\Column(name="country_name", type="string", length=255, nullable=true)
  60.      */
  61.     private $countryName;
  62.     /**
  63.      * Concatenation of country + city to easier search
  64.      *
  65.      * @var string
  66.      * @ORM\Column(name="country_city_code", type="string", length=255, nullable=true)
  67.      */
  68.     private $countryCityCode;
  69.     /**
  70.      * @var string
  71.      * @ORM\Column(name="city_name", type="string", length=255, nullable=true)
  72.      */
  73.     private $cityName;
  74.     /**
  75.      * @var string
  76.      * @ORM\Column(name="organizationId", type="string", length=255, nullable=true)
  77.      */
  78.     private $organizationId;
  79.     /**
  80.      * @var string
  81.      * @ORM\Column(name="organizationCode", type="string", length=255, nullable=true)
  82.      */
  83.     private $organizationCode;
  84.     /**
  85.      * @var string
  86.      * @ORM\Column(name="organizationName", type="string", length=255, nullable=true)
  87.      */
  88.     private $organizationName;
  89.     /**
  90.      * @var string
  91.      * @ORM\Column(name="code", type="string", length=255)
  92.      */
  93.     private $code;
  94.     /**
  95.      * @var string
  96.      * @ORM\Column(name="description", type="text", nullable=true)
  97.      */
  98.     private $description;
  99.     /**
  100.      * @var string
  101.      * @ORM\Column(name="postal_address", type="text", nullable=true)
  102.      */
  103.     private $postalAddress;
  104.     /**
  105.      * @var string
  106.      * @ORM\Column(name="lat_lng", type="string", nullable=true)
  107.      */
  108.     private $latLng;
  109.     /**
  110.      * @ORM\ManyToOne(targetEntity="App\Application\Sonata\MediaBundle\Entity\Media", cascade={"persist"}, fetch="LAZY")
  111.      */
  112.     private $image;
  113.     /**
  114.      * @ORM\ManyToOne(targetEntity="App\Entity\Event", inversedBy="nodes", cascade={"persist"})
  115.      * @ORM\JoinColumn(name="event_id", referencedColumnName="id")
  116.      */
  117.     private $event;
  118.     /**
  119.      * FROM NEOS
  120.      * @ORM\OneToMany(targetEntity="\App\Entity\EventFacility", mappedBy="eventNode", cascade={"persist","remove"}, orphanRemoval=false)
  121.      * @ORM\OrderBy({"text" = "ASC"})
  122.      */
  123.     private $facilities;
  124.     /**
  125.      * @ORM\ManyToMany(targetEntity="App\Entity\EventContact", cascade={"persist"})
  126.      * @ORM\JoinTable(name="event_contact_facilities",
  127.      *      joinColumns={@ORM\JoinColumn(name="facility_id", referencedColumnName="id")},
  128.      *      inverseJoinColumns={@ORM\JoinColumn(name="event_contact_id", referencedColumnName="id")}
  129.      *      )
  130.      */
  131.     private $eventContacts;
  132.     /**
  133.      * @ORM\ManyToMany(targetEntity="App\Entity\Document", cascade={"persist"})
  134.      * @ORM\JoinTable(name="document_facilities",
  135.      *      joinColumns={@ORM\JoinColumn(name="facility_id", referencedColumnName="id")},
  136.      *      inverseJoinColumns={@ORM\JoinColumn(name="document_id", referencedColumnName="id")}
  137.      *      )
  138.      */
  139.     private $documents;
  140.     /**
  141.      * Node constructor.
  142.      */
  143.     public function __construct()
  144.     {
  145.         $this->documents = new ArrayCollection();
  146.         $this->facilities = new ArrayCollection();
  147.         $this->eventContacts = new ArrayCollection();
  148.     }
  149.     /**
  150.      * @return string
  151.      */
  152.     public function getOrganizationId(): ?string
  153.     {
  154.         return $this->organizationId;
  155.     }
  156.     /**
  157.      * @param string $organizationId
  158.      */
  159.     public function setOrganizationId(string $organizationId null): void
  160.     {
  161.         $this->organizationId $organizationId;
  162.     }
  163.     /**
  164.      * @return string
  165.      */
  166.     public function getOrganizationCode(): ?string
  167.     {
  168.         if (empty($this->organizationCode) && $this->getEvent() != null && $this->getEvent()->getEventGroupContactsHost() != null) {
  169.             return $this->getEvent()->getEventGroupContactsHost()->getCode();
  170.         }
  171.         return $this->organizationCode;
  172.     }
  173.     /**
  174.      * @param string $organizationCode
  175.      */
  176.     public function setOrganizationCode(string $organizationCode null): void
  177.     {
  178.         $this->organizationCode $organizationCode;
  179.     }
  180.     /**
  181.      * Get event
  182.      *
  183.      * @return Event
  184.      */
  185.     public function getEvent()
  186.     {
  187.         return $this->event;
  188.     }
  189.     /**
  190.      * Set event
  191.      *
  192.      * @param Event $event
  193.      *
  194.      * @return Node
  195.      */
  196.     public function setEvent(Event $event null)
  197.     {
  198.         $this->event $event;
  199.         return $this;
  200.     }
  201.     /**
  202.      * @return string
  203.      */
  204.     public function getOrganizationName(): ?string
  205.     {
  206.         if (empty($this->organizationName) && $this->getEvent() != null && $this->getEvent()->getEventGroupContactsHost() != null) {
  207.             return $this->getEvent()->getEventGroupContactsHost()->getName();
  208.         }
  209.         return $this->organizationName;
  210.     }
  211.     /**
  212.      * @param string $organizationName
  213.      */
  214.     public function setOrganizationName(?string $organizationName): void
  215.     {
  216.         $this->organizationName $organizationName;
  217.     }
  218.     /**
  219.      * @return string
  220.      */
  221.     public function getStatus(): ?string
  222.     {
  223.         return $this->status;
  224.     }
  225.     /**
  226.      * @param string $status
  227.      */
  228.     public function setStatus(string $status): void
  229.     {
  230.         $this->status $status;
  231.     }
  232.     /**
  233.      * @return mixed
  234.      */
  235.     public function getCountryCityCode()
  236.     {
  237.         return $this->countryCityCode;
  238.     }
  239.     public function updateCountryCityCode()
  240.     {
  241.         $this->countryCityCode Location::buildCountryCityCode($this->getCountryCode(), $this->getCityCode());
  242.     }
  243.     /**
  244.      * @return string
  245.      */
  246.     public function getCountryCode(): ?string
  247.     {
  248.         return $this->countryCode;
  249.     }
  250.     /**
  251.      * @param string $countryCode
  252.      */
  253.     public function setCountryCode(string $countryCode null)
  254.     {
  255.         $this->countryCode $countryCode;
  256.     }
  257.     /**
  258.      * @return string
  259.      */
  260.     public function getCityCode(): ?string
  261.     {
  262.         return $this->cityCode;
  263.     }
  264.     /**
  265.      * @param string $cityCode
  266.      */
  267.     public function setCityCode(string $cityCode null)
  268.     {
  269.         $this->cityCode $cityCode;
  270.     }
  271.     /**
  272.      * Add contact
  273.      *
  274.      *
  275.      * @param EventContact $eventContact
  276.      * @return Node
  277.      */
  278.     public function addEventContact(EventContact $eventContact)
  279.     {
  280.         $this->eventContacts->add($eventContact);
  281.         return $this;
  282.     }
  283.     /**
  284.      * Remove contact
  285.      *
  286.      * @param EventContact $eventContact
  287.      */
  288.     public function removeEventContact(EventContact $eventContact)
  289.     {
  290.         $this->eventContacts->removeElement($eventContact);
  291.     }
  292.     /**
  293.      * @return mixed
  294.      */
  295.     public function getEventContacts()
  296.     {
  297.         return $this->eventContacts;
  298.     }
  299.     /**
  300.      * Add document
  301.      *
  302.      *
  303.      * @param Document $document
  304.      * @return Node
  305.      */
  306.     public function addDocument(Document $document)
  307.     {
  308.         $this->documents->add($document);
  309.         return $this;
  310.     }
  311.     /**
  312.      * Remove document
  313.      *
  314.      * @param Document $document
  315.      */
  316.     public function removeDocument(Document $document)
  317.     {
  318.         $this->documents->removeElement($document);
  319.     }
  320.     /**
  321.      * @return mixed
  322.      */
  323.     public function getDocuments()
  324.     {
  325.         return $this->documents;
  326.     }
  327.     /**
  328.      * @return mixed
  329.      */
  330.     public function getCountryName()
  331.     {
  332.         return $this->countryName;
  333.     }
  334.     /**
  335.      * @param mixed $countryName
  336.      */
  337.     public function setCountryName($countryName)
  338.     {
  339.         $this->countryName $countryName;
  340.     }
  341.     /**
  342.      * @return string
  343.      */
  344.     public function getCode(): string
  345.     {
  346.         return $this->code;
  347.     }
  348.     /**
  349.      * @param string $code
  350.      */
  351.     public function setCode(string $code)
  352.     {
  353.         $this->code $code;
  354.     }
  355.     /**
  356.      * Add facility
  357.      *
  358.      *
  359.      * @param EventFacility $facility
  360.      * @return Node
  361.      */
  362.     public function addFacility(EventFacility $facility)
  363.     {
  364.         $facility->setEventNode($this);
  365.         $this->facilities[] = $facility;
  366.         return $this;
  367.     }
  368.     /**
  369.      * Remove facility
  370.      *
  371.      * @param EventFacility $facility
  372.      */
  373.     public function removeFacility(EventFacility $facility)
  374.     {
  375.         $this->facilities->removeElement($facility);
  376.     }
  377.     public function getFacilitiesAsArray()
  378.     {
  379.         if ($this->getFacilities() == null) {
  380.             return [];
  381.         }
  382.         return $this->getFacilities()->getValues();
  383.     }
  384.     /**
  385.      * Get facilities
  386.      *
  387.      * @return Collection
  388.      */
  389.     public function getFacilities()
  390.     {
  391.         return $this->facilities;
  392.     }
  393.     /**
  394.      * @return string
  395.      */
  396.     public function getCityName(): ?string
  397.     {
  398.         return $this->cityName;
  399.     }
  400.     /**
  401.      * @param string $cityName
  402.      */
  403.     public function setCityName(string $cityName null)
  404.     {
  405.         $this->cityName $cityName;
  406.     }
  407.     public function toString(): string
  408.     {
  409.         return "{id=" $this->id "}";
  410.     }
  411.     public function __toString()
  412.     {
  413.         return (string)$this->title;
  414.     }
  415.     public function uploadImage()
  416.     {
  417.     }
  418.     /**
  419.      * Get image
  420.      *
  421.      * @return Media
  422.      */
  423.     public function getImage(): ?Media
  424.     {
  425.         return $this->image;
  426.     }
  427.     /**
  428.      * Set image
  429.      *
  430.      * @param Media $image
  431.      *
  432.      * @return Node
  433.      */
  434.     public function setImage(Media $image null)
  435.     {
  436.         $this->image $image;
  437.         return $this;
  438.     }
  439.     /**
  440.      * Get id
  441.      *
  442.      * @return int
  443.      */
  444.     public function getId()
  445.     {
  446.         return $this->id;
  447.     }
  448.     /**
  449.      * @param int $id
  450.      */
  451.     public function setId(int $id): void
  452.     {
  453.         $this->id $id;
  454.     }
  455.     /**
  456.      * Get nodeId
  457.      *
  458.      * @return string
  459.      */
  460.     public function getNodeId()
  461.     {
  462.         return $this->nodeId;
  463.     }
  464.     /**
  465.      * Set nodeId
  466.      *
  467.      * @param string $nodeId
  468.      *
  469.      * @return Node
  470.      */
  471.     public function setNodeId($nodeId)
  472.     {
  473.         $this->nodeId $nodeId;
  474.         return $this;
  475.     }
  476.     /**
  477.      * @return string the title
  478.      */
  479.     public function getName()
  480.     {
  481.         return $this->getTitle();
  482.     }
  483.     /**
  484.      * Get title
  485.      *
  486.      * @return string
  487.      */
  488.     public function getTitle()
  489.     {
  490.         return $this->title;
  491.     }
  492.     /**
  493.      * Set title
  494.      *
  495.      * @param string $title
  496.      *
  497.      * @return Node
  498.      */
  499.     public function setTitle($title)
  500.     {
  501.         $this->title $title;
  502.         return $this;
  503.     }
  504.     /**
  505.      * Get description
  506.      *
  507.      * @return string
  508.      */
  509.     public function getDescription()
  510.     {
  511.         return $this->description;
  512.     }
  513.     /**
  514.      * Set description
  515.      *
  516.      * @param string $description
  517.      *
  518.      * @return Node
  519.      */
  520.     public function setDescription($description)
  521.     {
  522.         $this->description $description;
  523.         return $this;
  524.     }
  525.     /**
  526.      * Get postalAdress
  527.      *
  528.      * @return string
  529.      */
  530.     public function getPostalAddress()
  531.     {
  532.         return $this->postalAddress;
  533.     }
  534.     /**
  535.      * Set postalAdress
  536.      *
  537.      * @param string $postalAddress
  538.      *
  539.      * @return Node
  540.      */
  541.     public function setPostalAddress($postalAddress)
  542.     {
  543.         $this->postalAddress $postalAddress;
  544.         return $this;
  545.     }
  546.     /**
  547.      * Get longLat
  548.      *
  549.      * @return string
  550.      */
  551.     public function getLatLng()
  552.     {
  553.         return $this->latLng;
  554.     }
  555.     /**
  556.      * Set longLat
  557.      *
  558.      * @param string $latLng
  559.      *
  560.      * @return Node
  561.      */
  562.     public function setLatLng($latLng)
  563.     {
  564.         $this->latLng $latLng;
  565.         return $this;
  566.     }
  567. }