Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
browser.php
1
<?php
2
10
namespace
Bitrix\Main\Web\UserAgent
;
11
12
use
Bitrix\Main
;
13
use
Bitrix\Main\DI
;
14
15
class
Browser
16
{
17
protected
$name
;
18
protected
$platform
;
19
protected
$deviceType
=
DeviceType::UNKNOWN
;
20
protected
$userAgent
;
21
27
public
function
__construct
(?
string
$name
=
null
, ?
string
$platform
=
null
, ?
int
$deviceType
=
null
)
28
{
29
$this->name =
$name
;
30
$this->platform =
$platform
;
31
if
(
$deviceType
!==
null
)
32
{
33
$this->deviceType =
$deviceType
;
34
}
35
}
36
40
public
function
getName
(): ?string
41
{
42
return
$this->name
;
43
}
44
49
public
function
setName
(?
string
$name
):
Browser
50
{
51
$this->name =
$name
;
52
return
$this;
53
}
54
58
public
function
getPlatform
(): ?string
59
{
60
return
$this->platform
;
61
}
62
67
public
function
setPlatform
(?
string
$platform
):
Browser
68
{
69
$this->platform =
$platform
;
70
return
$this;
71
}
72
76
public
function
getDeviceType
(): int
77
{
78
return
$this->deviceType
;
79
}
80
85
public
function
setDeviceType
(
int
$deviceType
):
Browser
86
{
87
$this->deviceType =
$deviceType
;
88
return
$this;
89
}
90
94
public
function
getUserAgent
(): ?string
95
{
96
return
$this->userAgent
;
97
}
98
103
public
function
setUserAgent
(?
string
$userAgent
)
104
{
105
$this->userAgent =
$userAgent
;
106
return
$this;
107
}
108
113
public
static
function
detect
(?
string
$userAgent
=
null
):
Browser
114
{
115
$serviceLocator = DI\ServiceLocator::getInstance();
116
117
if
($serviceLocator->has(
'main.browserDetector'
))
118
{
119
$detector = $serviceLocator->get(
'main.browserDetector'
);
120
}
121
else
122
{
123
$detector =
new
Detector
();
124
}
125
126
if
(
$userAgent
===
null
)
127
{
128
$userAgent
= Main\Context::getCurrent()->getServer()->getUserAgent();
129
}
130
131
return
$detector->detectBrowser(
$userAgent
);
132
}
133
}
Bitrix\Main\Web\UserAgent\Browser
Definition
browser.php:16
Bitrix\Main\Web\UserAgent\Browser\getName
getName()
Definition
browser.php:40
Bitrix\Main\Web\UserAgent\Browser\getUserAgent
getUserAgent()
Definition
browser.php:94
Bitrix\Main\Web\UserAgent\Browser\__construct
__construct(?string $name=null, ?string $platform=null, ?int $deviceType=null)
Definition
browser.php:27
Bitrix\Main\Web\UserAgent\Browser\$userAgent
$userAgent
Definition
browser.php:20
Bitrix\Main\Web\UserAgent\Browser\getDeviceType
getDeviceType()
Definition
browser.php:76
Bitrix\Main\Web\UserAgent\Browser\setPlatform
setPlatform(?string $platform)
Definition
browser.php:67
Bitrix\Main\Web\UserAgent\Browser\setName
setName(?string $name)
Definition
browser.php:49
Bitrix\Main\Web\UserAgent\Browser\$platform
$platform
Definition
browser.php:18
Bitrix\Main\Web\UserAgent\Browser\detect
static detect(?string $userAgent=null)
Definition
browser.php:113
Bitrix\Main\Web\UserAgent\Browser\$name
$name
Definition
browser.php:17
Bitrix\Main\Web\UserAgent\Browser\$deviceType
$deviceType
Definition
browser.php:19
Bitrix\Main\Web\UserAgent\Browser\getPlatform
getPlatform()
Definition
browser.php:58
Bitrix\Main\Web\UserAgent\Browser\setDeviceType
setDeviceType(int $deviceType)
Definition
browser.php:85
Bitrix\Main\Web\UserAgent\Browser\setUserAgent
setUserAgent(?string $userAgent)
Definition
browser.php:103
Bitrix\Main\Web\UserAgent\Detector
Definition
detector.php:13
Bitrix\Main\Web\UserAgent\DeviceType\UNKNOWN
const UNKNOWN
Definition
devicetype.php:16
Bitrix\Main\DI
Definition
servicelocator.php:3
Bitrix\Main\Web\UserAgent
Definition
browser.php:10
Bitrix\Main
modules
main
lib
web
useragent
browser.php
Создано системой
1.10.0