-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUseragentAPI.php
More file actions
executable file
·41 lines (35 loc) · 1.03 KB
/
UseragentAPI.php
File metadata and controls
executable file
·41 lines (35 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Statamic\Addons\Useragent;
use Jenssegers\Agent\Agent;
use Statamic\Extend\API;
class UseragentAPI extends API
{
/** @var array */
private $data;
protected function init()
{
// Initialize UA
$agent = new Agent();
$browser = $agent->browser();
// Assemble data
$this->data = [
'browser' => $browser,
'browser_version' => $agent->version($browser),
'languages' => array($agent->languages()),
'device' => $agent->device(),
'platform' => $agent->platform(),
'is_mobile' => $agent->isMobile(),
'is_tablet' => $agent->isTablet(),
'is_desktop' => $agent->isDesktop(),
'is_robot' => $agent->isRobot(),
'robot_name' => $agent->robot()
];
}
/**
* Accessed by $this->api('Useragent')->getUA() from other addons
*/
public function getUA()
{
return $this->data;
}
}