Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F2751456
CustomHeaderDeviceDetector.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
CustomHeaderDeviceDetector.php
View Options
<?php
namespace
MobileFrontend\Devices
;
use
MediaWiki\Config\Config
;
use
MediaWiki\Request\WebRequest
;
/**
* Detects mobile devices by testing whether a custom request header is present.
*
* @note See README.md for more detail on `$wgMFMobileHeader`.
*/
class
CustomHeaderDeviceDetector
implements
DeviceDetector
{
/**
* The name of the custom request header.
*
* @var string
*/
private
$customHeaderName
;
/**
* @param Config $config The global config. Currently this can be any instance
* of `GlobalVarConfig`.
*
* @todo In future, however, this should probably be a MobileFrontend-specific
* instance. `GlobalVarConfig#__construct` accepts a custom prefix to avoid
* repeating prefixes in `#get` calls, e.g.
*
* ```
* $config = new GlobalVarConfig();
* $mobileFrontendConfig = new GlobalVarConfig( 'wgMF' );
*
* assert(
* $config->get( 'MFMobileHeader' )
* === $mobileFrontendConfig->get( 'MobileHeader' )
* );
* ```
*/
public
function
__construct
(
Config
$config
)
{
$this
->
customHeaderName
=
$config
->
get
(
'MFMobileHeader'
);
}
/**
* @inheritDoc
*/
public
function
detectDeviceProperties
(
WebRequest
$request
,
array
$server
)
{
if
(
$this
->
customHeaderName
&&
$request
->
getHeader
(
$this
->
customHeaderName
)
!==
false
)
{
return
new
DeviceProperties
(
true
,
false
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Jul 3, 18:35 (1 d, 14 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f4/12/275921914a1c21d7d2aa6139664f
Default Alt Text
CustomHeaderDeviceDetector.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment