<?php
/**
 * Menu Controller
 *
 * @author Elze Kool <info@visualmedia.nl>
 */

namespace VisualM\ManagementBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

/**
 * Menu Controller
 *
 * @author Elze Kool <info@visualmedia.nl>
 */
class MenuController extends Controller
{
    /**
     * Render Menu
     *
     * @return Response Response
     */
    public function renderAction()
    {        
        if (null === ($menu_service_name = $this->container->getParameter('visual_m_management_menu_provider'))) {
            return new Response('');
        }

        $menu_provider = $this->container->get($menu_service_name);
        $items = $menu_provider->getItems();
        $request_stack = $this->get('request_stack');
        
        return $this->render('VisualMManagementBundle:Menu:menu.html.twig', [
            'items' => $items,
            'request' => $request_stack->getMasterRequest()
        ]);

    }
}