Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5988118
CodeMirrorHooks.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
CodeMirrorHooks.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Scribunto
;
use
MediaWiki\Config\Config
;
use
MediaWiki\Extension\CodeMirror\Hooks\CodeMirrorGetModeHook
;
use
MediaWiki\Title\Title
;
/**
* Hooks from CodeMirror extension,
* which is optional to use with this extension.
*/
class
CodeMirrorHooks
implements
CodeMirrorGetModeHook
{
private
bool
$useCodeMirror
;
public
function
__construct
(
Config
$config
,
private
readonly
EngineFactory
$engineFactory
,
)
{
$this
->
useCodeMirror
=
$config
->
get
(
'ScribuntoUseCodeMirror'
);
}
/**
* @param Title $title
* @param string|null &$mode
* @param string $model
* @return bool
*/
public
function
onCodeMirrorGetMode
(
Title
$title
,
?
string
&
$mode
,
string
$model
):
bool
{
if
(
$this
->
useCodeMirror
&&
$title
->
hasContentModel
(
CONTENT_MODEL_SCRIBUNTO
)
)
{
$engine
=
$this
->
engineFactory
->
getDefaultEngine
();
if
(
$engine
->
getCodeMirrorLanguage
()
)
{
$mode
=
$engine
->
getCodeMirrorLanguage
();
return
false
;
}
}
return
true
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Oct 4, 00:41 (2 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
63/c6/9eecc86365c6d38825bdc637c4b3
Default Alt Text
CodeMirrorHooks.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment