<?php
use WpBookingHotel\Factory as FactoryAlias;
use WpBookingHotel\Html\WpBookingHotelHtmlFrontend as WpBookingHotelHtmlFrontendAlias;
use WpBookingHotelBlock\block_trending_destinations_hotel\block_trending_destinations_hotel_helper;
use WpBookingHotelFrontend\app\helpers\ConfigHelper as ConfigHelperAlias;

require_once __DIR__.DS."block_trending_destinations_hotel_helper.php";
$params=$this->item->params;
$filter_by_country=$params->get('filter_by_country',array());
$list_hotel_location=block_trending_destinations_hotel_helper::getList_Hotel_location($filter_by_country);
$list_hotel_all = array();
foreach ($list_hotel_location as $hotel_location) {
    foreach ($hotel_location->list_location as $location) {
        array_push($list_hotel_all,$location->list_hotel);
    }
}
$list_hotel_all = call_user_func_array("array_merge",$list_hotel_all);
foreach ($list_hotel_all as &$hotel_item) {
    if(is_array($hotel_item) && empty($hotel_item)) {
        unset($hotel_item);
    }
}

$layout = $this->item->params->get('layout', 'default');
$plugin_name=WPBOOKINGHOTEL_PLUGIN_NAME;
$template_path=get_template_directory();
$block_name= basename(__DIR__);
$layout_name="tmpl/$layout.php";
$template1_path="$template_path/$plugin_name/blocks/$block_name/$layout_name";
$template2_path= __DIR__ . "/tmpl/$layout.php";
if(file_exists($template1_path)){
    require $template1_path;
}else{
    require $template2_path;
}

?>