public function __construct(Restaurant $restaurant) { $this->id = $restaurant->getId(); $this->name = $restaurant->getName(); $this->latitude = $restaurant->getLatitude(); $this->longitude = $restaurant->getLongitude(); }
public function __construct(Restaurant $restaurant, $container) { $this->floors = $restaurant->getFloors(); // get big and small $provider = $container->get('sonata.media.pool')->getProvider($restaurant->getMapPhoto()->getProviderName()); $formatSmall = $provider->getFormatName($restaurant->getMapPhoto(), "small"); $formatBig = $provider->getFormatName($restaurant->getMapPhoto(), "big"); $smallImageURL = $container->getParameter('site_host') . $provider->generatePublicUrl($restaurant->getMapPhoto(), $formatSmall); $bigImageURL = $container->getParameter('site_host') . $provider->generatePublicUrl($restaurant->getMapPhoto(), $formatBig); $photo = array("small" => $smallImageURL, "big" => $bigImageURL); $this->mapPhoto = $photo; }
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; }
/** * @param \Table\RestaurantBundle\Entity\Restaurant $restaurant * * @return void */ public function prePersist($restaurant) { $object = $this->getRoot()->getSubject(); foreach ($object->getRestaurantSchedule() as $restaurantSchedule) { $restaurantSchedule->setRestaurant($object); } // set for photos restaurant foreach ($object->getAdditionalPhotos() as $additionalPhoto) { $additionalPhoto->setRestaurant($object); } // set for photos restaurant foreach ($object->getAdditionalMenuPhotos() as $menuPhoto) { $menuPhoto->setRestaurant($object); } // update latitude/longitude $latitude = $restaurant->calculateLatitude(); $object->setLatitude($latitude); $longitude = $restaurant->calculateLongitude(); $object->setLongitude($longitude); // Add link to admin $container = $this->getConfigurationPool()->getContainer(); $linkInAdminDashboard = $container->getParameter('site_host') . $container->get('router')->generate('table_viewCreateMap', array('restaurantId' => $object->getId())); $object->setLinkInAdminDashboard($linkInAdminDashboard); }