Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4051441
LoggedInUserMode.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
979 B
Referenced Files
None
Subscribers
None
LoggedInUserMode.php
View Options
<?php
namespace
MobileFrontend\Features
;
use
MediaWiki\User\User
;
/**
* An easy way to enable features only for logged in users.
* This class is an Adapter for the User object to fulfill FeaturesManager requirements.
* Instead of hardcoding ` if ( $user->isRegistered() ) { ` logic in each feature code,
* we can re-use this mode and have `isRegistered` check only in one place for all features.
*
* To use it please define feature like that:
*
* $wgMFMyNewFeature => [
* ...
* 'loggedin' => true,
* ];
*
* @package MobileFrontend\Features
*/
class
LoggedInUserMode
implements
IUserMode
{
/**
* @var User
*/
private
$user
;
/**
* @param User $user
*/
public
function
__construct
(
User
$user
)
{
$this
->
user
=
$user
;
}
/**
* @inheritDoc
*/
public
function
isEnabled
()
{
return
$this
->
user
->
isSafeToLoad
()
&&
$this
->
user
->
isRegistered
();
}
/**
* @inheritDoc
*/
public
function
getModeIdentifier
()
{
return
'loggedin'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 15 2026, 18:05 (12 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
2a/e9/b94c26709f1df111edeb58571d77
Default Alt Text
LoggedInUserMode.php (979 B)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment