<?php

namespace App\Controller;

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

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

        $locale = $request->getLocale();

        $curl = curl_init();
        curl_setopt_array($curl, array(

            CURLOPT_URL => "https://admin.telheirodoinfante.com/api/getContentArticle/restorant/$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);

        $menu1 = json_decode($response);

        return $this->render('pricemenu/index.html.twig', [
            'controller_name' => 'Menu Telheiro do Infante',
            'menu' => $menu1
        ]);
    }
}
