csvxml/scripts/buildClassMap.php

40 lines
816 B
PHP
Raw Permalink Normal View History

2021-03-06 12:45:51 +01:00
<?PHP
/**
* Generates a class map, based on a constant AUTOLOAD_DIRS.
*
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
*/
declare(strict_types = 1);
require_once __DIR__ . '/../inc/constants.php';
$classesToAutoload = [];
// Load list of classes
foreach (AUTOLOAD_DIRS as $dir) {
$dir = str_replace(realpath(__DIR__ . "/../") . "/inc/../", "", $dir);
foreach (glob($dir . "/*.php") as $file) {
$classesToAutoload[pathinfo(__DIR__ . '/../' . $file, PATHINFO_FILENAME)] = $file;
}
}
// Output
$output = [];
foreach ($classesToAutoload as $key => $value) {
$output[] = ' \'' . $key . '\' => __DIR__ . \'/../' . $value . '\',';
}
$toWrite = '<?PHP
const AUTOLOAD_CLASS_MAP = [
' . implode(PHP_EOL, $output) . '
];';
file_put_contents("tmp-class-map.php", $toWrite);