'string', 'address_2' => 'string', 'zip_code' => 'string', 'city' => 'string', 'state' => 'string', 'country' => 'string', 'website_url' => 'string', 'lng' => 'string', 'lat' => 'string', 'display_on_site' => 'boolean', 'details_page' => 'boolean', 'location_message' => 'string', 'images' => 'array', ]; /** * @return array */ public static function getMetadata(){ return array_merge(SummitAbstractLocation::getMetadata(), self::$metadata); } /** * @param SummitVenueRoom|null $room * @return string */ public function getFullAddress(SummitVenueRoom $room = null){ $full_location = $this->getName().', '; if(!is_null($room)){ $floor = $room->getFloor(); if(!is_null($floor)){ $full_location .= $floor->getName().', '; } $full_location .= $room->getName().', '; } if(!empty($this->getAddress1())) $full_location .= $this->getAddress1().', '; if(!empty($this->getAddress2())) $full_location .= $this->getAddress2().', '; if(!empty($this->getCity())) $full_location .= $this->getCity().', '; if(!empty($this->getState())) $full_location .= $this->getState().', '; if(!empty($this->getZipCode())) $full_location .= $this->getZipCode().', '; if(!empty($this->getCountry)) $full_location .= $this->getCountry().', '; return rtrim($full_location, ', '); } /** * @return mixed */ public function getAddress1() { return $this->address1; } /** * @param mixed $address1 */ public function setAddress1($address1) { $this->address1 = $address1; } /** * @return mixed */ public function getAddress2() { return $this->address2; } /** * @param mixed $address2 */ public function setAddress2($address2) { $this->address2 = $address2; } /** * @return mixed */ public function getZipCode() { return $this->zip_code; } /** * @param mixed $zip_code */ public function setZipCode($zip_code) { $this->zip_code = $zip_code; } /** * @return mixed */ public function getCity() { return $this->city; } /** * @param mixed $city */ public function setCity($city) { $this->city = $city; } /** * @return mixed */ public function getState() { return $this->state; } /** * @param mixed $state */ public function setState($state) { $this->state = $state; } /** * @return mixed */ public function getCountry() { return $this->country; } /** * @param mixed $country */ public function setCountry($country) { $this->country = $country; } /** * @return mixed */ public function getWebsiteUrl() { return $this->website_url; } /** * @param mixed $website_url */ public function setWebsiteUrl($website_url) { $this->website_url = $website_url; } /** * @return mixed */ public function getLng() { return $this->lng; } /** * @param mixed $lng */ public function setLng($lng) { $this->lng = $lng; } /** * @return mixed */ public function getLat() { return $this->lat; } /** * @param mixed $lat */ public function setLat($lat) { $this->lat = $lat; } /** * @return mixed */ public function getDisplayOnSite() { return $this->display_on_site; } /** * @param mixed $display_on_site */ public function setDisplayOnSite($display_on_site) { $this->display_on_site = $display_on_site; } /** * @return mixed */ public function getDetailsPage() { return $this->details_page; } /** * @param mixed $details_page */ public function setDetailsPage($details_page) { $this->details_page = $details_page; } /** * @return mixed */ public function getLocationMessage() { return $this->location_message; } /** * @param mixed $location_message */ public function setLocationMessage($location_message) { $this->location_message = $location_message; } public function __construct() { parent::__construct(); $this->details_page = false; $this->display_on_site = false; $this->images = new ArrayCollection; } /** * @return SummitLocationImage[] */ public function getMaps() { return $this->images ->matching ( Criteria::create() ->where(Criteria::expr()->eq("class_name", SummitLocationImage::TypeMap)) ->orderBy(["order" => Criteria::ASC]) ); } /** * @return SummitLocationImage[] */ public function getImages() { return $this->images ->matching ( Criteria::create() ->where(Criteria::expr()->eq("class_name", SummitLocationImage::TypeImage)) ->orderBy(array("order" => Criteria::ASC)) ); } /** * @param int $image_id * @return SummitLocationImage */ public function getImage($image_id){ $res = $this->images ->matching ( Criteria::create() ->where(Criteria::expr()->eq("id", $image_id)) ->andWhere(Criteria::expr()->eq("class_name", SummitLocationImage::TypeImage)) )->first(); return $res === false ? null : $res; } /** * @param int $map_id * @return SummitLocationImage */ public function getMap($map_id){ $res = $this->images ->matching ( Criteria::create()->where(Criteria::expr()->eq("id", $map_id))->andWhere(Criteria::expr()->eq("class_name", SummitLocationImage::TypeMap)) )->first(); return $res === false ? null : $res; } /** * @param SummitLocationImage $map */ public function addMap(SummitLocationImage $map){ $maps = $this->getMaps(); $maps_count = count($maps); $new_order = $maps_count > 0 ? $maps_count + 1 : 1; $map->setOrder($new_order); $this->images->add($map); $map->setLocation($this); } /** * @param SummitLocationImage $map * @return $this */ public function removeMap(SummitLocationImage $map){ $this->images->removeElement($map); $map->ClearLocation(); return $this; } /** * @param SummitLocationImage $image */ public function addImage(SummitLocationImage $image){ $images = $this->getImages(); $images_count = count($images); $new_order = $images_count > 0 ? $images_count + 1 : 1; $image->setOrder($new_order); $this->images->add($image); $image->setLocation($this); } /** * @param SummitLocationImage $image * @return $this */ public function removeImage(SummitLocationImage $image){ $this->images->removeElement($image); $image->ClearLocation(); return $this; } /** * @param SummitLocationImage $map * @param $new_order * @throws ValidationException */ public function recalculateMapOrder(SummitLocationImage $map, $new_order){ $maps = $this->getMaps(); $maps = array_slice($maps,0, count($maps), false); $max_order = count($maps); $former_order = 1; foreach ($maps as $m){ if($m->getId() == $map->getId()) break; $former_order++; } if($new_order > $max_order) throw new ValidationException(sprintf("max order is %s", $max_order)); unset($maps[$former_order - 1]); $maps = array_merge ( array_slice($maps, 0, $new_order -1 , true) , [$map] , array_slice($maps, $new_order -1 , count($maps), true) ); $order = 1; foreach($maps as $m){ $m->setOrder($order); $order++; } } /** * @param SummitLocationImage $image * @param $new_order * @throws ValidationException */ public function recalculateImageOrder(SummitLocationImage $image, $new_order){ $images = $this->getImages(); $images = array_slice($images,0, count($images), false); $max_order = count($images); $former_order = 1; foreach ($images as $i){ if($i->getId() == $image->getId()) break; $former_order++; } if($new_order > $max_order) throw new ValidationException(sprintf("max order is %s", $max_order)); unset($images[$former_order - 1]); $images = array_merge ( array_slice($images, 0, $new_order -1 , true) , [$image] , array_slice($images, $new_order -1 , count($images), true) ); $order = 1; foreach($images as $i){ $i->setOrder($order); $order++; } } }