Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6036044
NotificationPager.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
NotificationPager.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications\Special
;
use
LogicException
;
use
MediaWiki\Context\IContextSource
;
use
MediaWiki\Extension\Notifications\DbFactory
;
use
MediaWiki\Extension\Notifications\Model\Notification
;
use
MediaWiki\Extension\Notifications\Services
;
use
MediaWiki\Pager\ReverseChronologicalPager
;
/**
* This pager is used by Special:Notifications (NO-JS).
* The heavy-lifting is done by IndexPager (grand-parent to this class).
* It paginates on notification_event for a specific user, only for the enabled event types.
*/
class
NotificationPager
extends
ReverseChronologicalPager
{
public
function
__construct
(
IContextSource
$context
)
{
$dbFactory
=
DbFactory
::
newFromDefault
();
$this
->
mDb
=
$dbFactory
->
getEchoDb
(
DB_REPLICA
);
parent
::
__construct
(
$context
);
}
/** @inheritDoc */
public
function
formatRow
(
$row
)
{
// @phan-suppress-previous-line PhanPluginNeverReturnMethod LSP violation
throw
new
LogicException
(
"This pager does not support row formatting. "
.
"Use 'getNotifications()' to get a list of Notification objects."
);
}
/** @inheritDoc */
public
function
getQueryInfo
()
{
$attributeManager
=
Services
::
getInstance
()->
getAttributeManager
();
$eventTypes
=
$attributeManager
->
getUserEnabledEvents
(
$this
->
getUser
(),
'web'
);
return
[
'tables'
=>
[
'echo_notification'
,
'echo_event'
],
'fields'
=>
Notification
::
selectFields
(),
'conds'
=>
[
'notification_user'
=>
$this
->
getUser
()->
getId
(),
'event_type'
=>
$eventTypes
,
'event_deleted'
=>
0
,
],
'options'
=>
[],
'join_conds'
=>
[
'echo_event'
=>
[
'JOIN'
,
'notification_event=event_id'
,
],
],
];
}
/**
* @return Notification[]
*/
public
function
getNotifications
()
{
if
(
!
$this
->
mQueryDone
)
{
$this
->
doQuery
();
}
$notifications
=
[];
foreach
(
$this
->
mResult
as
$row
)
{
$notifications
[]
=
Notification
::
newFromRow
(
$row
);
}
// get rid of the overfetched
if
(
count
(
$notifications
)
>
$this
->
getLimit
()
)
{
array_pop
(
$notifications
);
}
if
(
$this
->
mIsBackwards
)
{
$notifications
=
array_reverse
(
$notifications
);
}
return
$notifications
;
}
/** @inheritDoc */
public
function
getIndexField
()
{
return
'notification_event'
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 4 2026, 19:20 (5 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f8/37/df3ec5ef0c49ea7435d0a702f1d8
Default Alt Text
NotificationPager.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment