<?php
namespace AWCmsBundle\Controller;
use Doctrine\ORM\EntityManagerInterface;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use AWCmsBundle\Entity\Site;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
/**
* Class HealthCheckController
*
* @package AWCmsBundle\Controller
* @author David Courtey
*/
class HealthCheckController extends AbstractController
{
/**
* @Route("/healthcheck", name="awcms_healthcheck", options={"i18n"=false})
* @param EntityManagerInterface $entityManager
* @param SessionInterface $session
* @return Response
* @throws \Exception
*/
public function healthCheckAction(EntityManagerInterface $entityManager, SessionInterface $session)
{
$entityManager->getRepository(Site::class)->findAll();
$session->set('healthcheck_tester', 'foo');
if($session->get('healthcheck_tester') != 'foo'){
throw new \Exception('Session test fail');
}
return new Response('ok '.disk_free_space("/"));
}
/**
* @Route("/exception", name="awcms_exception", options={"i18n"=false})
* @throws \Exception
*/
public function exceptionAction()
{
throw new \Exception('Exception tester');
}
}