Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4125651
EchoEventDigestFormatter.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
EchoEventDigestFormatter.php
View Options
<?php
namespace
MediaWiki\Extension\Notifications\Formatters
;
use
MediaWiki\Extension\Notifications\Model\Event
;
use
MediaWiki\Language\Language
;
use
MediaWiki\Message\Message
;
use
MediaWiki\User\User
;
/**
* Abstract class for formatters that process multiple events.
*
* The formatter does not maintain any state except for the
* arguments passed in the constructor (user and language)
*/
abstract
class
EchoEventDigestFormatter
{
/** @var User */
protected
$user
;
/** @var Language */
protected
$language
;
public
function
__construct
(
User
$user
,
Language
$language
)
{
$this
->
user
=
$user
;
$this
->
language
=
$language
;
}
/**
* Equivalent to IContextSource::msg for the current
* language
*
* @param string $key
* @param mixed ...$params
* @return Message
*/
protected
function
msg
(
string
$key
,
...
$params
)
{
$msg
=
wfMessage
(
$key
,
...
$params
);
$msg
->
inLanguage
(
$this
->
language
);
return
$msg
;
}
/**
* @param Event[] $events
* @param string $distributionType 'web' or 'email'
* @return string[]|false Output format depends on implementation, false if it cannot be formatted
*/
final
public
function
format
(
array
$events
,
$distributionType
)
{
$models
=
[];
foreach
(
$events
as
$event
)
{
$model
=
EchoEventPresentationModel
::
factory
(
$event
,
$this
->
language
,
$this
->
user
,
$distributionType
);
if
(
$model
->
canRender
()
)
{
$models
[]
=
$model
;
}
}
return
$models
?
$this
->
formatModels
(
$models
)
:
false
;
}
/**
* @param EchoEventPresentationModel[] $models
* @return string[]|string
*/
abstract
protected
function
formatModels
(
array
$models
);
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 07:35 (2 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5b/9e/f8ddea76754544b83e67a7c2573b
Default Alt Text
EchoEventDigestFormatter.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment