Completed
Push — master ( 65f14b...342827 )
by Stephan
05:11
created

SemanticGlossary::initExtension()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 25
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 25
rs 8.8571
cc 3
eloc 13
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
				ApplicationFactory::getInstance()->getStore()
36
			);
37
38
			$hookRegistry->register();
39
		};
40
	}
41
42
	/**
43
	 * @since 2.0
44
	 *
45
	 * @return string|null
46
	 */
47
	public static function getVersion() {
48
		$extensionData = ExtensionRegistry::getInstance()->getAllThings();
49
50
		if ( isset( $extensionData['Semantic Glossary'] ) ) {
51
			return $extensionData['Semantic Glossary']['version'];
52
		}
53
54
		return null;
55
	}
56
}
57