<?php
namespace JF\JuridicusBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class DefaultController extends AbstractController
{
/**
* @Route("/impressum.html", name="impressum")
*/
public function impressumAction()
{
$response = $this->render('@JFJuridicusBundle/Static/show_impressum.html.twig');
$response->setETag(md5($response->getContent()));
$request = $this->container->get('request_stack')->getCurrentRequest();
$response->isNotModified($request);
return $response;
}
/**
* @Route("/datenschutz.html", name="datenschutz")
*/
public function datenschutzAction()
{
$response = $this->render('@JFJuridicusBundle/Static/show_datenschutz.html.twig');
$response->setETag(md5($response->getContent()));
$request = $this->container->get('request_stack')->getCurrentRequest();
$response->isNotModified($request);
return $response;
}
/**
* @Route("/kooperationspartner.html", name="kooperationspartner")
*/
public function kooperationspartnerAction()
{
$response = $this->render('@JFJuridicusBundle/Static/show_kooperationspartner.html.twig');
$response->setETag(md5($response->getContent()));
$request = $this->container->get('request_stack')->getCurrentRequest();
$response->isNotModified($request);
return $response;
}
/**
* @Route("/sitemap.xml", name="sitemap")
*/
public function sitemapAction()
{
$em = $this->getDoctrine()->getManager();
$anzahl_termine = $em->getRepository('JFJuridicusBundle:Pruefung')->countTermine();
$termine_per_page = $this->container->getParameter('max_termine_on_page');
$last_page = ceil($anzahl_termine / $termine_per_page);
$pruefungsaemter = $em->getRepository('JFJuridicusBundle:Pruefungsamt')->findWithPrueferAndProtokoll();
$response = $this->render("JFJuridicusBundle::sitemap.xml.twig", array(
'numpages' => $last_page,
'pruefungsaemter' => $pruefungsaemter
));
$response->headers->set('Content-Type', 'application/xml; charset=UTF-8');
return $response;
}
/**
*
*/
public function agbAction()
{
$response = $this->render('@JFJuridicusBundle/Static/show_agb.html.twig');
$response->setETag(md5($response->getContent()));
$request = $this->container->get('request_stack')->getCurrentRequest();
$response->isNotModified($request);
return $response;
}
/**
*/
public function redirectAction()
{
$em = $this->getDoctrine()->getManager();
$anzahl_termine = $em->getRepository('JFJuridicusBundle:Pruefung')->countTermine();
$termine_per_page = $this->container->getParameter('max_termine_on_page');
$last_page = ceil($anzahl_termine / $termine_per_page);
$pruefungsaemter = $em->getRepository('JFJuridicusBundle:Pruefungsamt')->findWithPrueferAndProtokoll();
$response = $this->render("JFJuridicusBundle::redirect.txt.twig", array(
'numpages' => $last_page,
'pruefungsaemter' => $pruefungsaemter
));
$response->headers->set('Content-Type', 'text/plain; charset=UTF-8');
return $response;
}
/**
* @Route("/apc_clear", name="apc_clear")
*/
public function apcClearAction(Request $request)
{
$ip = $request->server->get('REMOTE_ADDR');
if (in_array($ip, array('127.0.0.1', '::1'))) {
apc_clear_cache();
apc_clear_cache('user');
apc_clear_cache('opcode');
$jsonData = array('success' => true);
} else {
throw new AccessDeniedException('SUPER TOP SECRET');
}
return new JsonResponse($jsonData);
}
}