Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4087559
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
Aug 18 2026, 09:36 (6 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0e/57/236876fd183b73f8471b74c4d856
Default Alt Text
CustomHeaderDeviceDetector.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment