-
Notifications
You must be signed in to change notification settings - Fork 0
/
_autoload.php
154 lines (151 loc) · 5 KB
/
_autoload.php
1
2
3
4
5
6
7
8
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of Mage Pattern.
# The toolkit PHP for developer
# Copyright (C) 2012 - 2013 Gerits Aurelien contact[at]aurelien-gerits[dot]be
#
# OFFICIAL TEAM MAGE PATTERN:
#
# * Gerits Aurelien (Author - Developer) contact[at]aurelien-gerits[dot]be
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# DISCLAIMER
# Do not edit or add to this file if you wish to upgrade Mage Pattern to newer
# versions in the future. If you wish to customize Mage Pattern for your
# needs please refer to http://www.magepattern.com for more information.
#
# -- END LICENSE BLOCK -----------------------------------
/**
* Autoload pour la librairie
*/
final class magepattern_bootstrap{
/**
* @var bool
*/
private static $_instance = false;
/**
* On indique que le constructeur est privé pour éviter
* toute instanciation non maîtrisée
*/
private function __construct(){}
/**
* On évite tout clonage pour ne pas avoir deux instances en //
*/
private function __clone(){}
/**
* C'est la méthode qui "remplace" le constructeur vis à vis
* des autres classes.
*
* Son rôle est de créer / distribuer une unique
* instance de notre objet.
*/
public static function getInstance(){
//Si l'instance n'existe pas encore, alors elle est créée.
if (self::$_instance === false){
self::$_instance = new self;
}
//L'instance existe, on peut la retourner à l'extérieur.
return self::$_instance;
}
/**
* Constante Path swiftmailer lib
*/
private static $path_swiftmailer = '/package/Swift-5.2.1/lib/swift_required.php';
/**
* Constante Path Autoloader magepattern
*/
private static $path_autoloader = '/loader/autoloader.php';
/**
* Constante Path Firephp
*/
private static $path_firephp = '/package/firephp-1.0/FirePHP/Init.php';
/**
* Constante Path Chrome Logger
*/
private static $path_chrome_logger = '/package/chrome-logger/ChromePhp.php';
/**
* @var string
*/
private static $path_dompdf = '/package/dompdf/autoload.inc.php';
/**
* @var string
*/
private static $path_css_inliner = '/package/cssinliner/init.php';
/**
* @var string
*/
private static $path_css_Mobile_Detect = '/package/mobiledetect/Mobile_Detect.php';
/**
* @access private
* @return array
*/
private function arrayLibFiles(){
return array(
'autoloader' => __DIR__.self::$path_autoloader,
'firephp' => __DIR__.self::$path_firephp,
'chromephp' => __DIR__.self::$path_chrome_logger,
'swift' => __DIR__.self::$path_swiftmailer,
'dompdf' => __DIR__.self::$path_dompdf,
'cssinliner' => __DIR__.self::$path_css_inliner,
'mobiledetect' => __DIR__.self::$path_css_Mobile_Detect
);
}
/**
* @access private
* @throws Exception
*/
private function getFilesRequire(){
$setLibOption = self::arrayLibFiles();
if(is_array($setLibOption)){
foreach($setLibOption as $key => $value){
if (file_exists($value)){
require $value;
}else{
throw new Exception("not file exists for ".$key);
}
}
}
}
/**
* @access private
* @param $setClassLoader
*/
public function getClassAutoloader($setClassLoader){
if($this->getFilesRequire() != false){
$this->getFilesRequire();
}
if(is_array($setClassLoader)){
//$mp_autoloader = dirname(__FILE__).'/component/loader/autoloader.php';
$loader = new autoloader();
$loader->registerPrefixFallbacks($setClassLoader);
$loader->register();
}
}
}
/**
* Chargement des classes + des librairies
*/
magepattern_bootstrap::getInstance()->getClassAutoloader(array(
'loader' => __DIR__.'/loader',
'component' => __DIR__.'/component'
));
?>