Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4113951
DeviceDetectorService.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
DeviceDetectorService.php
View Options
<?php
namespace
MobileFrontend\Devices
;
use
MediaWiki\Config\Config
;
use
MediaWiki\Request\WebRequest
;
/**
* MobileFrontend's device detector.
*
* Detects the properties of a device by iterating over a list, //in order//,
* child device detectors until one returns a positive result.
*
* The order of the child device detectors is defined in
* `DeviceDetectorService::factory`.
*/
class
DeviceDetectorService
implements
DeviceDetector
{
/**
* Given MobileFrontend's configuration, creates a new instance of the device
* detector.
*
* If `$wgMFAutodetectMobileView` is falsy, then no device detection will
* occur.
*
* @param Config $config containing values for MFAutodetectMobileView and MFMobileHeader
* @return self
*/
public
static
function
factory
(
Config
$config
)
{
$children
=
[];
if
(
$config
->
get
(
'MFAutodetectMobileView'
)
)
{
array_push
(
$children
,
new
AMFDeviceDetector
(),
new
CustomHeaderDeviceDetector
(
$config
),
new
UADeviceDetector
()
);
}
return
new
self
(
$children
);
}
/**
* @var DeviceDetector[]
*/
private
$children
;
/**
* @param DeviceDetector[] $children
*/
public
function
__construct
(
array
$children
)
{
$this
->
children
=
$children
;
}
/**
* @inheritDoc
*/
public
function
detectDeviceProperties
(
WebRequest
$request
,
array
$server
)
{
foreach
(
$this
->
children
as
$child
)
{
$properties
=
$child
->
detectDeviceProperties
(
$request
,
$server
);
if
(
$properties
)
{
return
$properties
;
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 23:45 (11 h, 25 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a3/9d/bd2f22092a17a9ead6257ed5a160
Default Alt Text
DeviceDetectorService.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment