/** * @param $entityName * @param $type * @param null $depth * @param null $displayAll * * @return array */ private function generateChildren($entityName, $type, $depth = null, $displayAll = null) { $em = $this->entityManager; $children = array(); $brandId = $this->getBrandId(); $brandSlug = $this->getBrandSlug(); $entityRepository = $em->getRepository($entityName); $entities = $entityRepository->findAllForMenu(strpos($entityName, 'Hotel') === false || $brandSlug != 'seh' ? $brandId : null); foreach ($entities as $entity) { if (strpos($entityName, 'Hotel') !== false) { $brandName = $entity->getBrand()->getName(); $itemName = sprintf('%s %s', $entity->getName(), $brandName); $keyGroup = $brandName; } else { $itemName = $entity->getName(); $keyGroup = substr($entity->getName(), 0, 1); } if (strpos($entityName, 'Region') !== false) { $countryName = $entity->getCountry()->getName(); $countrySlug = $entity->getCountry()->getSlug(); if ($countryName && $countrySlug !== 'france') { $itemName = sprintf('%s (%s)', $itemName, $countryName); } } $child = new Menu\Item(); $child->setName($itemName); $child->setLabel($itemName); $child->setSlug(sprintf('%s-menu-item', $entity->getSlug())); try { $link = $this->urlManager->generateUrlByType($entity, $type, true); } catch (\Exception $e) { $link = '#'; } $child->setLink(array('externalLink' => $link)); if ($entity->getMenuThumbnail() && $entity->getMenuThumbnail()) { $child->setImage($entity->getMenuThumbnail()); } $children[$keyGroup][] = $child; } return $children; }
/** * @param Hotel $hotel * @return bool|string */ public function linkPage($slug, $absolute = false) { return $this->urlManager->generatePageUrl($slug, $absolute); }
/** * @param Hotel $hotel * @return bool|string */ public function linkHotel(Hotel $hotel, $absolute = false, $rate = null) { return $this->urlManager->generateHotelUrl($hotel, null, $absolute, $rate); }
/** * @param Hotel $hotel * @return bool|string */ public function linkThematic($slug, $absolute = false) { return $this->urlManager->generateThematicUrlFromSlug($slug, null, $absolute); }