Beispiel #1
0
 public function __construct(Restaurant $restaurant)
 {
     $this->id = $restaurant->getId();
     $this->name = $restaurant->getName();
     $this->latitude = $restaurant->getLatitude();
     $this->longitude = $restaurant->getLongitude();
 }
Beispiel #2
0
 public function __construct(Restaurant $restaurant, $container)
 {
     $this->id = $restaurant->getId();
     $this->name = $restaurant->getName();
     $this->rating = $restaurant->getRating();
     $this->description = $restaurant->getDescription();
     // get big and small
     $provider = $container->get('sonata.media.pool')->getProvider($restaurant->getPhoto()->getProviderName());
     $formatSmall = $provider->getFormatName($restaurant->getPhoto(), "small");
     $formatBig = $provider->getFormatName($restaurant->getPhoto(), "big");
     $smallImageURL = $container->getParameter('site_host') . $provider->generatePublicUrl($restaurant->getPhoto(), $formatSmall);
     $bigImageURL = $container->getParameter('site_host') . $provider->generatePublicUrl($restaurant->getPhoto(), $formatBig);
     $photo = array("small" => $smallImageURL, "big" => $bigImageURL);
     $this->photo = $photo;
     // get categories id
     $this->categories = array();
     $categories = $restaurant->getCategories();
     foreach ($categories as $category) {
         $this->categories[] = $category->getId();
     }
     $this->kitchens = array();
     foreach ($restaurant->getKitchens() as $kitchen) {
         $this->kitchens[] = $kitchen->getId();
     }
     $this->address = $restaurant->getCity() . ", " . $restaurant->getStreet() . ", " . $restaurant->getHouse();
     $this->latitude = $restaurant->getLatitude();
     $this->longitude = $restaurant->getLongitude();
     $this->additionalServices = array();
     foreach ($restaurant->getAdditionalServices() as $additionalService) {
         $this->additionalServices[] = $additionalService->getId();
     }
     // get Schedule
     $scheduleList = array();
     $restaurantSchedule = $restaurant->getRestaurantSchedule();
     foreach ($restaurantSchedule as $scheduleObj) {
         $schedule['dayFrom'] = $scheduleObj->getDayFromStr();
         $schedule['dayTo'] = $scheduleObj->getDayToStr();
         $schedule['timeFrom'] = $scheduleObj->getTimeFrom()->format('H:s');
         $schedule['timeTo'] = $scheduleObj->getTimeTo()->format('H:s');
         $scheduleList[] = $schedule;
     }
     $this->schedule = $scheduleList;
 }