1111use RuntimeException ;
1212use Symfony \Component \HttpFoundation \Request ;
1313use Symfony \Component \HttpFoundation \Response ;
14+ use function array_filter ;
15+ use function array_shift ;
16+ use function dirname ;
17+ use function explode ;
18+ use function file_get_contents ;
19+ use function ltrim ;
20+ use function md5 ;
21+ use function pathinfo ;
22+ use function realpath ;
23+ use function spl_autoload_functions ;
24+ use function str_replace ;
25+ use function str_split ;
26+ use function strlen ;
27+ use function substr ;
28+ use function trim ;
29+ use const DIRECTORY_SEPARATOR ;
30+ use const PATHINFO_EXTENSION ;
1431
1532class Dispatch
1633{
1734
35+ const RESOURCES_DIR = 'resources ' ;
36+ const VENDOR_DIR = 'vendor ' ;
37+ const PUBLIC_DIR = 'public ' ;
1838 /**
1939 * @var Dispatch
2040 */
2141 private static $ _instance ;
22-
2342 /**
2443 * @var ResourceStore
2544 */
2645 protected $ _resourceStore ;
27-
2846 protected $ _baseUri ;
2947 protected $ _requireFileHash = false ;
3048 /**
3149 * @var ConfigProvider
3250 */
3351 protected $ _config ;
34-
35- const RESOURCES_DIR = 'resources ' ;
36- const VENDOR_DIR = 'vendor ' ;
37- const PUBLIC_DIR = 'public ' ;
38-
39- public static function bind (Dispatch $ instance )
40- {
41- self ::$ _instance = $ instance ;
42- return $ instance ;
43- }
44-
45- public static function instance ()
46- {
47- return self ::$ _instance ;
48- }
49-
50- public static function destroy ()
51- {
52- self ::$ _instance = null ;
53- }
54-
5552 protected $ _aliases = [];
5653 protected $ _projectRoot ;
5754 protected $ _componentAliases = [];
@@ -70,6 +67,22 @@ public function __construct($projectRoot, $baseUri = null, ClassLoader $loader =
7067 $ this ->_classLoader = $ loader ;
7168 }
7269
70+ public static function bind (Dispatch $ instance )
71+ {
72+ self ::$ _instance = $ instance ;
73+ return $ instance ;
74+ }
75+
76+ public static function instance ()
77+ {
78+ return self ::$ _instance ;
79+ }
80+
81+ public static function destroy ()
82+ {
83+ self ::$ _instance = null ;
84+ }
85+
7386 /**
7487 * Add salt to dispatch hashes, for additional resource security
7588 *
@@ -253,6 +266,11 @@ public function handleRequest(Request $request): Response
253266 return ResourceFactory::create ($ resource );
254267 }
255268
269+ public function config ()
270+ {
271+ return $ this ->_config ;
272+ }
273+
256274 public function componentClassResourcePath ($ class )
257275 {
258276 $ loader = $ this ->_getClassLoader ();
@@ -291,11 +309,6 @@ public function store()
291309 return $ this ->_resourceStore ;
292310 }
293311
294- public function config ()
295- {
296- return $ this ->_config ;
297- }
298-
299312 public function calculateRelativePath ($ filePath )
300313 {
301314 return ltrim (str_replace ($ this ->_projectRoot , '' , $ filePath ), '/ \\' );
0 commit comments