Blame view

src/amdaintegration_autoload.php 3 KB
cc3bdb0e   Elena.Budnik   RequestManager sp...
1
2
<?php
//autoload configuration
6111df45   Benjamin Renard   Optimize autoload...
3

07745dea   Benjamin Renard   Do not use global...
4
5
class AutoloadData {
	private static $integration_dirs = NULL;
6111df45   Benjamin Renard   Optimize autoload...
6

07745dea   Benjamin Renard   Do not use global...
7
	private static $ihm_dirs = NULL;
6111df45   Benjamin Renard   Optimize autoload...
8

07745dea   Benjamin Renard   Do not use global...
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	private static $cache = NULL;

	public static function integration_dirs() {
		if (self::$integration_dirs == NULL) {
			self::$integration_dirs = array(
				'InputOutput',
				'InputOutput/IHMImpl',
				'InputOutput/IHMImpl/Config',
				'InputOutput/IHMImpl/Params',
				'InputOutput/IHMImpl/Params/DataMiningImpl',
				'InputOutput/IHMImpl/Params/StatisticsImpl',
				'InputOutput/IHMImpl/Params/DownloadImpl',
				'InputOutput/IHMImpl/Params/PlotImpl',
				'InputOutput/IHMImpl/Params/GeneratorImpl',
				'InputOutput/IHMImpl/Params/GenInfoParamImpl',
				'InputOutput/IHMImpl/Process',
				'InputOutput/IHMImpl/ParamInfo',
				'InputOutput/IHMImpl/Tools',
				'InputOutput/IHMImpl/TimeTables',
				'InputOutput/TestImpl',
				'InputOutput/WSImpl',
				'InputOutput/WSImpl/Config',
				'InputOutput/WSImpl/Process',
				'InputOutput/WSImpl/Params/DownloadImpl',
				'InputOutput/WSImpl/Params/PlotImpl',
				'InputOutput/WSImpl/Tools',
				'InputOutput/WSImpl/TimeTables',
				'InputOutput/SharedObjectsUpdater',
				'InputOutput/SharedObjectsUpdater/TimeTables',
				'Request',
				'Request/Config',
				'Request/ParamsRequestImpl',
				'Request/ParamsRequestImpl/Nodes',
				'Request/ParamsRequestImpl/Nodes/Infos',
				'Request/ParamsRequestImpl/Nodes/Params',
				'Request/ParamsRequestImpl/Nodes/Requests',
				'Request/ProcessRequestImpl',
				'Request/ProcessRequestImpl/Process',
				'Request/TTRequestImpl',
				'Request/ParserRequestImpl',
			);
		}
		return self::$integration_dirs;
	}

	public static function ihm_dirs() {
		if (self::$ihm_dirs == NULL) {
			self::$ihm_dirs = array(
				IHM_SRC_DIR.'/php/classes',
				IHM_SRC_DIR.'/php/RemoteDataCenter',
				IHM_SRC_DIR.'/php/WebServices',
				IHM_SRC_DIR.'/php/WebServices/Client'
			);
		}
		return self::$ihm_dirs;
	}

	public static function get_cache($class_name) {
		if (self::$cache == NULL) {
			self::$cache = array();
		}
		if (isset(self::$cache[$class_name])) {
			return self::$cache[$class_name];
		}
		return NULL;
	}

	public static function set_cache($class_name, $file) {
		if (self::$cache == NULL) {
			self::$cache = array();
		}
		self::$cache[$class_name] = $file;
	}
}
6111df45   Benjamin Renard   Optimize autoload...
83

cc3bdb0e   Elena.Budnik   RequestManager sp...
84
85
function amdaintegration_autoload($class_name)
{
07745dea   Benjamin Renard   Do not use global...
86
87
88
	$file = AutoloadData::get_cache($class_name);
	if (isset($file)) {
		require $file;
6111df45   Benjamin Renard   Optimize autoload...
89
90
91
		return;
	}

cc3bdb0e   Elena.Budnik   RequestManager sp...
92
93
94
95
96
	$file = __DIR__.'/'.$class_name.'.php';
	
	if (file_exists($file))
	{
		require $file;
07745dea   Benjamin Renard   Do not use global...
97
		AutoloadData::set_cache($class_name, $file);
cc3bdb0e   Elena.Budnik   RequestManager sp...
98
99
		return;	
	}
07745dea   Benjamin Renard   Do not use global...
100
101

	foreach(AutoloadData::integration_dirs() as $dir)
6111df45   Benjamin Renard   Optimize autoload...
102
103
104
	{
		$file = __DIR__.'/'.$dir.'/'.$class_name.'.php';
		if (file_exists($file))
cc3bdb0e   Elena.Budnik   RequestManager sp...
105
		{
6111df45   Benjamin Renard   Optimize autoload...
106
			require $file;
07745dea   Benjamin Renard   Do not use global...
107
			AutoloadData::set_cache($class_name, $file);
6111df45   Benjamin Renard   Optimize autoload...
108
			return;
cc3bdb0e   Elena.Budnik   RequestManager sp...
109
		}
6111df45   Benjamin Renard   Optimize autoload...
110
	}
cc3bdb0e   Elena.Budnik   RequestManager sp...
111
	
07745dea   Benjamin Renard   Do not use global...
112
	foreach(AutoloadData::ihm_dirs() as $dir)
6111df45   Benjamin Renard   Optimize autoload...
113
114
115
	{
		$file = $dir.'/'.$class_name.'.php';
		if (file_exists($file))
cc3bdb0e   Elena.Budnik   RequestManager sp...
116
		{
6111df45   Benjamin Renard   Optimize autoload...
117
			require $file;
07745dea   Benjamin Renard   Do not use global...
118
			AutoloadData::set_cache($class_name, $file);
6111df45   Benjamin Renard   Optimize autoload...
119
			break;
cc3bdb0e   Elena.Budnik   RequestManager sp...
120
		}
6111df45   Benjamin Renard   Optimize autoload...
121
	}
cc3bdb0e   Elena.Budnik   RequestManager sp...
122
123
124
125
126
}

spl_autoload_register('amdaintegration_autoload');

?>