Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7399503
BehaviorSwitchHandler.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
BehaviorSwitchHandler.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Wikimedia\Parsoid\Wt2Html\TT
;
use
Wikimedia\Parsoid\Tokens\KV
;
use
Wikimedia\Parsoid\Tokens\SelfclosingTagTk
;
use
Wikimedia\Parsoid\Tokens\Token
;
use
Wikimedia\Parsoid\Wt2Html\TokenTransformManager
;
/**
* Handler for behavior switches, like '__TOC__' and similar.
*/
class
BehaviorSwitchHandler
extends
TokenHandler
{
public
function
__construct
(
TokenTransformManager
$manager
,
array
$options
)
{
parent
::
__construct
(
$manager
,
$options
);
}
/**
* Main handler.
* See {@link TokenTransformManager#addTransform}'s transformation parameter.
*
* @param Token $token
* @return TokenHandlerResult
*/
public
function
onBehaviorSwitch
(
Token
$token
):
TokenHandlerResult
{
$env
=
$this
->
env
;
$magicWord
=
$env
->
getSiteConfig
()->
getMagicWordForBehaviorSwitch
(
$token
->
attribs
[
0
]->
v
);
$env
->
setBehaviorSwitch
(
$magicWord
,
true
);
$metaToken
=
new
SelfclosingTagTk
(
'meta'
,
[
new
KV
(
'property'
,
'mw:PageProp/'
.
$magicWord
)
],
$token
->
dataParsoid
->
clone
()
);
return
new
TokenHandlerResult
(
[
$metaToken
]
);
}
/**
* @inheritDoc
*/
public
function
onTag
(
Token
$token
):
?
TokenHandlerResult
{
return
$token
->
getName
()
===
'behavior-switch'
?
$this
->
onBehaviorSwitch
(
$token
)
:
null
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 16:03 (6 h, 30 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
45/07/4f8a173558187757a7bb7becf3bc
Default Alt Text
BehaviorSwitchHandler.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment