redireccion basica
This commit is contained in:
26
app/middlewares/DetectMobileDevice.php
Normal file
26
app/middlewares/DetectMobileDevice.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\middlewares;
|
||||
|
||||
use flight\Engine;
|
||||
use Tracy\Debugger;
|
||||
|
||||
class DetectMobileDevice
|
||||
{
|
||||
protected Engine $app;
|
||||
|
||||
public function __construct(Engine $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
public function before(array $params): void
|
||||
{
|
||||
$userAgent = $this->app->request()->user_agent;
|
||||
|
||||
$is_apple = preg_match('/iPhone|iPad|iPod/i', $userAgent);
|
||||
|
||||
$this->app->set('is_apple', $is_apple);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user