Skip to content

Commit

Permalink
Added mobile detection
Browse files Browse the repository at this point in the history
  • Loading branch information
rimi-itk committed Dec 12, 2024
1 parent 9946ad1 commit 09a721b
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"easycorp/easyadmin-bundle": "^4.6",
"fakerphp/faker": "^1.23",
"itk-dev/metrics-bundle": "^1.0",
"mobiledetect/mobiledetectlib": "^4.8",
"nelmio/cors-bundle": "^2.3",
"phpdocumentor/reflection-docblock": "^5.3",
"phpstan/phpdoc-parser": "^1.22",
Expand Down
118 changes: 117 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Service\AppManager;
use App\Service\AppManager\App;
use Detection\MobileDetect;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
Expand Down Expand Up @@ -35,6 +36,10 @@ public function show(string|int $id, ?string $path = null): Response
$url = App::buildUrl($app, $path ?? '');

// @todo Detect mobile device
$detect = new MobileDetect();
if ($detect->isMobile()) {
return $this->redirect($url);
}

return $this->render('app/show.html.twig', [
'the_app' => $app,
Expand Down

0 comments on commit 09a721b

Please sign in to comment.