-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoload.php
More file actions
33 lines (26 loc) · 799 Bytes
/
autoload.php
File metadata and controls
33 lines (26 loc) · 799 Bytes
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
<?php
require 'vendor/autoload.php';
spl_autoload_register(function ($class) {
if (strpos($class, 'Puzzle\\') !== 0) {
return;
}
$parts = explode('\\', $class);
if (count($parts) < 3) {
return;
}
if (!preg_match('/^[a-z_]+$/', $parts[1])) {
return;
}
$module = $parts[1];
$relativePath = implode(DIRECTORY_SEPARATOR, array_slice($parts, 2)) . '.php';
$filePaths = [
__DIR__ . '/core/modules/' . $module . '/src/' . $relativePath,
__DIR__ . '/modules/custom/' . $module . '/src/' . $relativePath,
__DIR__ . '/modules/contrib/' . $module . '/src/' . $relativePath,
];
foreach ($filePaths as $filePath) {
if (file_exists($filePath)) {
require_once $filePath;
}
}
});