julienmonnerie/kirby/config/setup.php

32 lines
606 B
PHP
Raw Permalink Normal View History

2022-06-17 17:51:59 +02:00
<?php
/**
* Class aliases
*/
$aliases = require_once __DIR__ . '/aliases.php';
spl_autoload_register(function ($class) use ($aliases) {
2022-08-31 15:02:43 +02:00
$class = strtolower($class);
2022-06-17 17:51:59 +02:00
2022-08-31 15:02:43 +02:00
if (isset($aliases[$class]) === true) {
class_alias($aliases[$class], $class);
}
2022-06-17 17:51:59 +02:00
});
/**
* Tests
*/
$testDir = dirname(__DIR__) . '/tests';
if (is_dir($testDir) === true) {
2022-08-31 15:02:43 +02:00
spl_autoload_register(function ($className) use ($testDir) {
$path = str_replace('Kirby\\', '', $className);
$path = str_replace('\\', '/', $path);
$file = $testDir . '/' . $path . '.php';
2022-06-17 17:51:59 +02:00
2022-08-31 15:02:43 +02:00
if (file_exists($file)) {
include $file;
}
});
2022-06-17 17:51:59 +02:00
}