Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4129614
ApiEchoPushSubscriptions.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ApiEchoPushSubscriptions.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications\Push\Api
;
use
MediaWiki\Api\ApiBase
;
use
MediaWiki\Api\ApiModuleManager
;
use
MediaWiki\Api\ApiUsageException
;
use
MediaWiki\MediaWikiServices
;
use
Wikimedia\ParamValidator\ParamValidator
;
/**
* API parent module for administering push subscriptions.
* Each operation (command) is implemented as a submodule. This module just performs some basic
* checks and dispatches the execute() call.
*/
class
ApiEchoPushSubscriptions
extends
ApiBase
{
/** array Module name => module class */
private
const
SUBMODULES
=
[
'create'
=>
ApiEchoPushSubscriptionsCreate
::
class
,
'delete'
=>
ApiEchoPushSubscriptionsDelete
::
class
,
];
/** @var ApiModuleManager */
private
$moduleManager
;
/** @inheritDoc */
public
function
execute
():
void
{
$this
->
checkLoginState
();
$this
->
checkUserRightsAny
(
'editmyprivateinfo'
);
$command
=
$this
->
getParameter
(
'command'
);
$module
=
$this
->
moduleManager
->
getModule
(
$command
,
'command'
);
$module
->
execute
();
$module
->
getResult
()->
addValue
(
null
,
$module
->
getModuleName
(),
[
'result'
=>
'Success'
]
);
}
/** @inheritDoc */
public
function
getModuleManager
():
ApiModuleManager
{
if
(
!
$this
->
moduleManager
)
{
$submodules
=
array_map
(
static
function
(
$class
)
{
return
[
'class'
=>
$class
,
'factory'
=>
"$class::factory"
,
];
},
self
::
SUBMODULES
);
$this
->
moduleManager
=
new
ApiModuleManager
(
$this
,
MediaWikiServices
::
getInstance
()->
getObjectFactory
()
);
$this
->
moduleManager
->
addModules
(
$submodules
,
'command'
);
}
return
$this
->
moduleManager
;
}
/** @inheritDoc */
protected
function
getAllowedParams
():
array
{
return
[
'command'
=>
[
ParamValidator
::
PARAM_TYPE
=>
'submodule'
,
ParamValidator
::
PARAM_REQUIRED
=>
true
,
],
];
}
/**
* Bail out with an API error if the user is not logged in.
* @throws ApiUsageException
*/
private
function
checkLoginState
():
void
{
if
(
!
$this
->
getUser
()->
isRegistered
()
)
{
$this
->
dieWithError
(
[
'apierror-mustbeloggedin'
,
$this
->
msg
(
'action-editmyprivateinfo'
)
],
'notloggedin'
);
}
}
/** @inheritDoc */
public
function
getHelpUrls
():
string
{
return
'https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:Echo#API'
;
}
/** @inheritDoc */
public
function
isWriteMode
():
bool
{
return
true
;
}
/** @inheritDoc */
public
function
needsToken
():
string
{
return
'csrf'
;
}
/** @inheritDoc */
public
function
isInternal
():
bool
{
// experimental!
return
true
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 09:59 (2 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
50/65/8db64baf050bb564884066c22f49
Default Alt Text
ApiEchoPushSubscriptions.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment