Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7428825
OptionalLoader.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
OptionalLoader.php
View Options
<?php
namespace
Cite\ResourceLoader
;
use
MediaWiki\Registration\ExtensionRegistry
;
use
MediaWiki\ResourceLoader\FileModule
;
use
MediaWiki\ResourceLoader\Module
;
/**
* @license MIT
*/
class
OptionalLoader
{
/**
* Add optional array values to a ResourceLoader module definition depending on loaded extensions.
*
* "optional": {
* "MyExtension": {
* "dependencies": [ ... ],
* "messages": [ ... ],
* "packageFiles": [ ... ],
* ...
* }
* }
*
* Copied from DiscussionTools
*/
public
static
function
addOptional
(
array
$info
):
Module
{
$extensionRegistry
=
ExtensionRegistry
::
getInstance
();
if
(
isset
(
$info
[
'optional'
]
)
)
{
foreach
(
$info
[
'optional'
]
as
$ext
=>
$extOptions
)
{
if
(
$extensionRegistry
->
isLoaded
(
$ext
)
)
{
foreach
(
$extOptions
as
$key
=>
$values
)
{
if
(
!
isset
(
$info
[
$key
]
)
)
{
$info
[
$key
]
=
[];
}
// TODO: Support non-array properties
$info
[
$key
]
=
array_merge
(
$info
[
$key
],
(
array
)
$values
);
}
}
}
}
$class
=
$info
[
'class'
]
??
FileModule
::
class
;
return
new
$class
(
$info
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 09:40 (13 h, 29 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
06/f6/d0e18759a08aa11ce2d8bb326300
Default Alt Text
OptionalLoader.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment