[DOCS][Dev] Add Routes and Controllers

This commit is contained in:
2021-08-01 12:44:45 +01:00
committed by Hugo Sales
parent 0c6088225f
commit ce39f6ca4a
2 changed files with 100 additions and 2 deletions

View File

@@ -32,6 +32,7 @@ namespace App\Core;
use App\Util\Common;
use App\Util\Exception\RedirectException;
use Exception;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
@@ -41,6 +42,7 @@ use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Event\ViewEvent;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
class Controller extends AbstractController implements EventSubscriberInterface
@@ -98,7 +100,7 @@ class Controller extends AbstractController implements EventSubscriberInterface
$template = $this->vars['_template'];
unset($this->vars['_template'], $this->vars['request']);
// Respond in the the most preffered acceptable content type
// Respond in the most preferred acceptable content type
$format = $request->getFormat($request->getAcceptableContentTypes()[0]);
switch ($format) {
case 'html':
@@ -159,7 +161,7 @@ class Controller extends AbstractController implements EventSubscriberInterface
return (bool) $value;
default:
Log::critical($m = "Method '{$method}' on class App\\Core\\Controller not found (__call)");
throw new \Exception($m);
throw new Exception($m);
}
}
}