<?php

/**
 * Generic Ajax Controller
 *
 * @author VisualMedia
 */

namespace VisualM\ManagementBundle\Controller;

use FOS\UserBundle\Entity\UserManager;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
 * Generic Ajax Controller
 *
 * 
 * @author VisualMedia
 */
class AjaxController extends Controller {
    
    /**
     * specify some action first
     * 
     */
    public function indexAction() {
        throw new NotFoundHttpException();
    }
    
    /**
     * checks if user is logged in
     *
     * @return Response Response
     */
    public function loginStatusAction(Request $request) {
        $loginStatus['loggedIn'] = $this->get('security.context')->isGranted('ROLE_USE_MANAGEMENT');

        return new Response(
                json_encode($loginStatus
                ), 200, array("Content-Type: text/json")
        );
    }
}

