35 lines
624 B
PHP
35 lines
624 B
PHP
<?php
|
|
|
|
namespace core;
|
|
|
|
/**
|
|
* Requires utils.php to be loaded before
|
|
*/
|
|
|
|
/**
|
|
* Autoloading function
|
|
*
|
|
* @param \string $class_name Name of the class (with namespace)
|
|
*
|
|
* @throws \Exception
|
|
*/
|
|
function load_class(class_name: \string $class_name)
|
|
{
|
|
$path = 'class' . \DIRECTORY_SEPARATOR . # WARNING: hard-coded path
|
|
\str_replace('\\', \DIRECTORY_SEPARATOR, $class_name) .
|
|
'.class.php';
|
|
|
|
if (\is_file($path))
|
|
{
|
|
require_once($path);
|
|
}
|
|
else
|
|
{
|
|
\throw new Exception(\core\substitute(
|
|
'the class {class} cannot be found in the path {path}',
|
|
array('class' => $class_name, 'path' => $path),
|
|
))
|
|
}
|
|
}
|
|
|
|
?>
|