26 lines
429 B
PHP
26 lines
429 B
PHP
<?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);
|
|
}
|
|
} |