. */ namespace App\Controller; use App\Services\LabelSystem\BarcodeParser; use Doctrine\ORM\EntityNotFoundException; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\Routing\Annotation\Route; /** * @Route("/scan") * @package App\Controller */ class ScanController extends AbstractController { protected $barcodeParser; public function __construct(BarcodeParser $barcodeParser) { $this->barcodeParser = $barcodeParser; } /** * The route definition for this action is done in routes.yaml, as it does not use the _locale prefix as the other routes * @param string $type * @param int $id */ public function scanQRCode(string $type, int $id) { try { $this->addFlash('success', 'scan.qr_success'); return $this->redirect($this->barcodeParser->getQRRedirectTarget($type, $id)); } catch (EntityNotFoundException $exception) { $this->addFlash('success', 'scan.qr_not_found'); return $this->redirectToRoute('homepage'); } } }