Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4123548
MathDataUpdater.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
MathDataUpdater.php
View Options
<?php
namespace
MediaWiki\Extension\Math
;
use
MediaWiki\Parser\ParserOutput
;
use
Wikibase\DataModel\Services\Entity\PropertyDataTypeMatcher
;
use
Wikibase\DataModel\Statement\Statement
;
use
Wikibase\Repo\ParserOutput\StatementDataUpdater
;
/**
* Add required styles for mathematical formulae to the ParserOutput.
*
* @license GPL-2.0-or-later
* @author Moritz Schubotz
*/
class
MathDataUpdater
implements
StatementDataUpdater
{
/** @var bool */
private
$hasMath
=
false
;
/**
* @var PropertyDataTypeMatcher
*/
private
$propertyDataTypeMatcher
;
/**
* @inheritDoc
*/
public
function
__construct
(
PropertyDataTypeMatcher
$propertyDataTypeMatcher
)
{
$this
->
propertyDataTypeMatcher
=
$propertyDataTypeMatcher
;
}
/**
* Extract some data or do processing on a Statement during parsing.
*
* This method is normally invoked when processing a StatementList
* for all Statements on a StatementListProvider (e.g. an Item).
*
* @param Statement $statement
*/
public
function
processStatement
(
Statement
$statement
)
{
$propertyId
=
$statement
->
getPropertyId
();
if
(
$this
->
propertyDataTypeMatcher
->
isMatchingDataType
(
$propertyId
,
'math'
)
)
{
$this
->
hasMath
=
true
;
}
}
/**
* Update extension data, properties or other data in ParserOutput.
* These updates are invoked when EntityContent::getParserOutput is called.
*
* @param ParserOutput $parserOutput
*/
public
function
updateParserOutput
(
ParserOutput
$parserOutput
)
{
if
(
$this
->
hasMath
)
{
$parserOutput
->
addModuleStyles
(
[
'ext.math.styles'
]
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 06:13 (6 d, 22 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
93/88/85a5460a53c64db341457809ee49
Default Alt Text
MathDataUpdater.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment