src/JuridicusBundle/Controller/DefaultController.php line 18

Open in your IDE?
  1. <?php
  2. namespace JF\JuridicusBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Component\HttpFoundation\JsonResponse;
  7. use Symfony\Component\Security\Core\Exception\AccessDeniedException;
  8. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  9. class DefaultController extends AbstractController
  10. {
  11. /**
  12. * @Route("/impressum.html", name="impressum")
  13. */
  14. public function impressumAction()
  15. {
  16. $response = $this->render('@JFJuridicusBundle/Static/show_impressum.html.twig');
  17. $response->setETag(md5($response->getContent()));
  18. $request = $this->container->get('request_stack')->getCurrentRequest();
  19. $response->isNotModified($request);
  20. return $response;
  21. }
  22. /**
  23. * @Route("/datenschutz.html", name="datenschutz")
  24. */
  25. public function datenschutzAction()
  26. {
  27. $response = $this->render('@JFJuridicusBundle/Static/show_datenschutz.html.twig');
  28. $response->setETag(md5($response->getContent()));
  29. $request = $this->container->get('request_stack')->getCurrentRequest();
  30. $response->isNotModified($request);
  31. return $response;
  32. }
  33. /**
  34. * @Route("/kooperationspartner.html", name="kooperationspartner")
  35. */
  36. public function kooperationspartnerAction()
  37. {
  38. $response = $this->render('@JFJuridicusBundle/Static/show_kooperationspartner.html.twig');
  39. $response->setETag(md5($response->getContent()));
  40. $request = $this->container->get('request_stack')->getCurrentRequest();
  41. $response->isNotModified($request);
  42. return $response;
  43. }
  44. /**
  45. * @Route("/sitemap.xml", name="sitemap")
  46. */
  47. public function sitemapAction()
  48. {
  49. $em = $this->getDoctrine()->getManager();
  50. $anzahl_termine = $em->getRepository('JFJuridicusBundle:Pruefung')->countTermine();
  51. $termine_per_page = $this->container->getParameter('max_termine_on_page');
  52. $last_page = ceil($anzahl_termine / $termine_per_page);
  53. $pruefungsaemter = $em->getRepository('JFJuridicusBundle:Pruefungsamt')->findWithPrueferAndProtokoll();
  54. $response = $this->render("JFJuridicusBundle::sitemap.xml.twig", array(
  55. 'numpages' => $last_page,
  56. 'pruefungsaemter' => $pruefungsaemter
  57. ));
  58. $response->headers->set('Content-Type', 'application/xml; charset=UTF-8');
  59. return $response;
  60. }
  61. /**
  62. *
  63. */
  64. public function agbAction()
  65. {
  66. $response = $this->render('@JFJuridicusBundle/Static/show_agb.html.twig');
  67. $response->setETag(md5($response->getContent()));
  68. $request = $this->container->get('request_stack')->getCurrentRequest();
  69. $response->isNotModified($request);
  70. return $response;
  71. }
  72. /**
  73. */
  74. public function redirectAction()
  75. {
  76. $em = $this->getDoctrine()->getManager();
  77. $anzahl_termine = $em->getRepository('JFJuridicusBundle:Pruefung')->countTermine();
  78. $termine_per_page = $this->container->getParameter('max_termine_on_page');
  79. $last_page = ceil($anzahl_termine / $termine_per_page);
  80. $pruefungsaemter = $em->getRepository('JFJuridicusBundle:Pruefungsamt')->findWithPrueferAndProtokoll();
  81. $response = $this->render("JFJuridicusBundle::redirect.txt.twig", array(
  82. 'numpages' => $last_page,
  83. 'pruefungsaemter' => $pruefungsaemter
  84. ));
  85. $response->headers->set('Content-Type', 'text/plain; charset=UTF-8');
  86. return $response;
  87. }
  88. /**
  89. * @Route("/apc_clear", name="apc_clear")
  90. */
  91. public function apcClearAction(Request $request)
  92. {
  93. $ip = $request->server->get('REMOTE_ADDR');
  94. if (in_array($ip, array('127.0.0.1', '::1'))) {
  95. apc_clear_cache();
  96. apc_clear_cache('user');
  97. apc_clear_cache('opcode');
  98. $jsonData = array('success' => true);
  99. } else {
  100. throw new AccessDeniedException('SUPER TOP SECRET');
  101. }
  102. return new JsonResponse($jsonData);
  103. }
  104. }