/** * @param array $data * @return string */ private function filterReservationData($data) { $currentDate = date('Y-m-d'); $cityDao = new City($this->getServiceLocator(), 'ArrayObject'); if (isset($data['city']) && ClassicValidator::checkCityName($data['city'])) { $cityResp = $cityDao->getCityByName(Helper::urlForSearch($data['city'])); if ($cityResp) { /* @var $websiteSearchService \DDD\Service\Website\Search */ $websiteSearchService = $this->getServiceLocator()->get('service_website_search'); $diffHours = $websiteSearchService->getDiffHoursForDate(); $currentDate = Helper::getCurrenctDateByTimezone($cityResp['timezone'], 'd-m-Y', $diffHours); } } if (!isset($data['city']) || !ClassicValidator::checkCityName($data['city']) || !isset($data['apartment']) || !ClassicValidator::checkApartmentTitle($data['apartment']) || !isset($data['guest']) || !is_numeric($data['guest']) || !isset($data['apartment_id']) || !is_numeric($data['apartment_id']) || !isset($data['arrival']) || !ClassicValidator::validateDate($data['arrival'], 'd M Y') || !isset($data['departure']) || !ClassicValidator::validateDate($data['departure'], 'd M Y') || strtotime($data['arrival']) >= strtotime($data['departure']) || strtotime($currentDate) - strtotime($data['arrival']) > 129600 || !isset($data['rate-for-booking']) || !is_numeric($data['rate-for-booking']) || isset($data['apartel_id']) && !is_numeric($data['apartel_id'])) { return false; } return true; }