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