Completed
Branch FET-9795-new-interfaces (ef7df2)
by
unknown
1355:51 queued 1341:30
created

EE_Psr4AutoloaderInit::initialize_psr4_loader()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 14
rs 9.4285
1
<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2
/**
3
 * Class EE_Psr4AutoloaderInit
4
 *
5
 * Loads the Psr4Autoloader class and registers namespaces
6
 *
7
 * @package 			Event Espresso
8
 * @subpackage 	core
9
 * @author 				Brent Christensen
10
 * @since 				4.8
11
 *
12
 */
13
14
class EE_Psr4AutoloaderInit {
15
16
17
	/**
18
	 * @type \EventEspresso\core\Psr4Autoloader
19
	 */
20
	protected static $psr4_loader;
21
22
	/**
23
	 * @access    public
24
	 */
25
	public function __construct() {
26
		EE_Psr4AutoloaderInit::initialize_psr4_loader();
27
	}
28
29
30
31
	/**
32
	 * @return \EventEspresso\core\Psr4Autoloader
33
	 */
34
	public static function initialize_psr4_loader() {
35
		static $initialized = false;
36
		if ( ! $initialized ) {
37
			// instantiate PSR4 autoloader
38
			espresso_load_required( 'Psr4Autoloader', EE_CORE . 'Psr4Autoloader.php' );
39
			EE_Psr4AutoloaderInit::$psr4_loader = new \EventEspresso\core\Psr4Autoloader();
40
			// register the autoloader
41
			EE_Psr4AutoloaderInit::$psr4_loader->register();
42
			// register the base directories for the namespace prefix
43
			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace( 'EventEspresso', EE_PLUGIN_DIR_PATH );
44
			EE_Psr4AutoloaderInit::$psr4_loader->addNamespace( 'EventEspressoBatchRequest', EE_LIBRARIES . 'batch' );
45
			$initialized = true;
46
		}
47
	}
48
49
50
51
	/**
52
	 * @return \EventEspresso\core\Psr4Autoloader
53
	 */
54
	public static function psr4_loader() {
55
		return self::$psr4_loader;
56
	}
57
58
59
60
}
61
// End of file EE_Psr4AutoloaderInit.core.php
62
// Location: /core/EE_Psr4AutoloaderInit.core.php