<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class GalleryController extends AbstractController
{
    /**
     * @Route("/gallery", name="gallery")
     */
    public function index(Request $request)
    {


        $locale = $request->getLocale();

        $curl = curl_init();

        curl_setopt_array($curl, array(

            CURLOPT_URL => "https://admin.telheirodoinfante.com/api/getContentGalleryList/$locale",
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "GET",
            CURLOPT_HTTPHEADER => array(
                "cache-control: no-cache"
            ),
        ));



        $response = curl_exec($curl);
        $err = curl_error($curl);

        curl_close($curl);


        $gallery_list = json_decode($response);


        $curl2 = curl_init();

        curl_setopt_array($curl2, array(

            CURLOPT_URL => "https://admin.telheirodoinfante.com/api/getContentGalleryAll/$locale",
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "GET",
            CURLOPT_HTTPHEADER => array(
                "cache-control: no-cache"
            ),
        ));



        $response2 = curl_exec($curl2);
        $err = curl_error($curl2);

        curl_close($curl2);


        $gallery_photos = json_decode($response2);



//      dd($gallery_photos);


//        $images_full = $gallery_list[0]->images;


        return $this->render('gallery/index.html.twig', [
            'controller_name' => 'Galeria',
            'list_gal' => $gallery_list,
            'list_photos' => $gallery_photos

        ]);
    }
}
