Skip to content

Commit

Permalink
Merge pull request #22 from oveleon/develop
Browse files Browse the repository at this point in the history
Use PageNotFoundException on non-existing vcard routes
  • Loading branch information
zoglo authored Jul 9, 2023
2 parents c40ae96 + 5940c88 commit baa6f87
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Controller/vCardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Oveleon\ContaoCompanyBundle\Controller;

use Contao\CoreBundle\Exception\PageNotFoundException;
use Contao\Environment;
use Contao\PageModel;
use Oveleon\ContaoCompanyBundle\Generator\vCardGenerator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
Expand Down Expand Up @@ -30,7 +32,7 @@ public function download(Request $request): Response

if (null === ($pageModel = PageModel::findById($pageId)))
{
throw new \Exception('Could not load correct redirect page');
throw new PageNotFoundException('Page not found: ' . Environment::get('uri'));
}

try {
Expand All @@ -48,6 +50,6 @@ public function download(Request $request): Response
$headers = [];
}

return new Response($vcf, 200, $headers);
return new Response($vcf, Response::HTTP_OK, $headers);
}
}

0 comments on commit baa6f87

Please sign in to comment.