xiaowang/kirby/config/setup.php

38 lines
684 B
PHP
Raw Permalink Normal View History

2021-10-29 18:05:46 +02:00
<?php
/**
* Constants
2022-12-19 16:26:24 +01:00
* @deprecated 3.8.0 Use `/` instead
2021-10-29 18:05:46 +02:00
*/
define('DS', '/');
/**
* Class aliases
*/
$aliases = require_once __DIR__ . '/aliases.php';
spl_autoload_register(function ($class) use ($aliases) {
2022-08-31 16:08:03 +02:00
$class = strtolower($class);
2021-10-29 18:05:46 +02:00
2022-08-31 16:08:03 +02:00
if (isset($aliases[$class]) === true) {
class_alias($aliases[$class], $class);
}
2021-10-29 18:05:46 +02:00
});
/**
* Tests
*/
$testDir = dirname(__DIR__) . '/tests';
if (is_dir($testDir) === true) {
2022-08-31 16:08:03 +02:00
spl_autoload_register(function ($className) use ($testDir) {
$path = str_replace('Kirby\\', '', $className);
$path = str_replace('\\', '/', $path);
$file = $testDir . '/' . $path . '.php';
2021-10-29 18:05:46 +02:00
2022-08-31 16:08:03 +02:00
if (file_exists($file)) {
include $file;
}
});
2021-10-29 18:05:46 +02:00
}