Completed
Push — master ( 94847e...d52f9e )
by mw
02:57
created

SemanticGlossary::initExtension()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
cc 3
eloc 12
nc 4
nop 0
1
<?php
2
3
use SG\HookRegistry;
4
use SMW\ApplicationFactory;
5
6
/**
7
 * Class SemanticGlossary
8
 *
9
 * @ingroup Skins
10
 */
11
class SemanticGlossary {
12
13
	/**
14
	 * @since 2.0
15
	 */
16
	public static function initExtension() {
17
18
		if ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {
19
			require_once __DIR__ . '/vendor/autoload.php';
20
		}
21
22
		// must NOT use ExtensionRegistry::getInstance() to avoid recursion!
23
		$registry = new ExtensionRegistry();
24
		if ( file_exists( __DIR__ . '/extensions/Lingo/extension.json' ) ) {
25
			$registry->load( __DIR__ . '/extensions/Lingo/extension.json' );
26
		} else {
27
			$registry->load( $GLOBALS[ 'wgExtensionDirectory' ] . '/Lingo/extension.json' );
28
		}
29
30
		$GLOBALS[ 'wgexLingoBackend' ] = 'SG\LingoBackendAdapter';
31
32
		$GLOBALS[ 'wgExtensionFunctions' ][] = function () {
33
34
			$hookRegistry = new HookRegistry();
35
36
			$hookRegistry->register();
37
		};
38
	}
39
40
	/**
41
	 * @since 2.0
42
	 *
43
	 * @return string|null
44
	 */
45
	public static function getVersion() {
46
		$extensionData = ExtensionRegistry::getInstance()->getAllThings();
47
48
		if ( isset( $extensionData['Semantic Glossary'] ) ) {
49
			return $extensionData['Semantic Glossary']['version'];
50
		}
51
52
		return null;
53
	}
54
}
55