Completed
Pull Request — master (#12)
by Stephan
20:19
created

SemanticGlossary::initExtension()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 8
nc 1
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
		// must NOT use ExtensionRegistry::getInstance() to avoid recursion!
19
		$registry = new ExtensionRegistry();
20
		$registry->load( $GLOBALS[ 'wgExtensionDirectory' ] . '/Lingo/extension.json' );
21
22
		$GLOBALS[ 'wgexLingoBackend' ] = 'SG\LingoBackendAdapter';
23
24
		$GLOBALS[ 'wgExtensionFunctions' ][] = function () {
25
26
			$hookRegistry = new HookRegistry(
27
				ApplicationFactory::getInstance()->getStore()
28
			);
29
30
			$hookRegistry->register();
31
		};
32
	}
33
34
	/**
35
	 * @since 2.0
36
	 *
37
	 * @return string|null
38
	 */
39
	public static function getVersion() {
40
		$extensionData = ExtensionRegistry::getInstance()->getAllThings();
41
42
		if ( isset( $extensionData['Semantic Glossary'] ) ) {
43
			return $extensionData['Semantic Glossary']['version'];
44
		}
45
46
		return null;
47
	}
48
}
49