Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5972713
InsertablesAid.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
InsertablesAid.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Translate\TranslatorInterface\Aid
;
use
MediaWiki\Extension\Translate\TranslatorInterface\TranslationHelperException
;
/**
* Translation aid that suggests insertables. Insertable is a string that
* usually does not need translation and is difficult to type manually.
* @ingroup TranslationAids
* @author Niklas Laxström
* @license GPL-2.0-or-later
* @since 2013.09
*/
class
InsertablesAid
extends
TranslationAid
{
public
function
getData
():
array
{
// We need to get the primary group to get the correct file
// So $group can be different from $this->group
$group
=
$this
->
handle
->
getGroup
();
if
(
!
$group
)
{
throw
new
TranslationHelperException
(
'Message handle '
.
$this
->
handle
->
getTitle
()->
getPrefixedDbKey
()
.
' has no associated group'
);
}
// This was added later, so not all classes have it. In addition
// the message group class hierarchy doesn't lend itself easily
// to the user of interfaces for this purpose.
if
(
!
method_exists
(
$group
,
'getInsertablesSuggester'
)
)
{
throw
new
TranslationHelperException
(
'Group does not have insertable suggesters'
);
}
// @phan-suppress-next-line PhanUndeclaredMethod
$suggester
=
$group
->
getInsertablesSuggester
();
// It is okay to return null suggester
if
(
!
$suggester
)
{
throw
new
TranslationHelperException
(
'Group does not have insertable suggesters'
);
}
$insertables
=
$suggester
->
getInsertables
(
$this
->
dataProvider
->
getDefinition
()
);
$blob
=
[];
foreach
(
$insertables
as
$insertable
)
{
$displayText
=
$insertable
->
getDisplayText
();
// The keys are used for de-duplication
$blob
[
$displayText
]
=
[
'display'
=>
$displayText
,
'pre'
=>
$insertable
->
getPreText
(),
'post'
=>
$insertable
->
getPostText
(),
];
}
$blob
=
array_values
(
$blob
);
$blob
[
'**'
]
=
'insertable'
;
return
$blob
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 16:06 (1 d, 17 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f8/21/2fa98fec4332c7a738a611255fb4
Default Alt Text
InsertablesAid.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment