From 829977e6511ecf4f57a1564734658c1601e2f7d2 Mon Sep 17 00:00:00 2001 From: tchapi Date: Sat, 20 Jan 2024 20:55:23 +0100 Subject: [PATCH] feat: disable the toolbar on dav/* routes --- config/services.yaml | 2 ++ src/Controller/DAVController.php | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/services.yaml b/config/services.yaml index 5f0d79f..b5e7271 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -14,6 +14,8 @@ services: autowire: true # Automatically injects dependencies in your services. autoconfigure: true # Automatically registers your services as commands, event subscribers, etc. + Symfony\Component\HttpKernel\Profiler\Profiler: '@profiler' + # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name App\: diff --git a/src/Controller/DAVController.php b/src/Controller/DAVController.php index 14a9edb..cd5e517 100644 --- a/src/Controller/DAVController.php +++ b/src/Controller/DAVController.php @@ -16,6 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Profiler\Profiler; use Symfony\Component\Mailer\MailerInterface; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; @@ -289,8 +290,11 @@ private function initExceptionListener() } #[Route('/dav/{path}', name: 'dav', requirements: ['path' => '.*'])] - public function dav(Request $request, string $path) + public function dav(Request $request, Profiler $profiler, string $path) { + // We don't want the toolbar on the /dav/* routes + $profiler->disable(); + // We need to acknowledge the OPTIONS call before sabre/dav for public // calendars since we're circumventing the lib if ('OPTIONS' === $request->getMethod()) {