Skip to content
Snippets Groups Projects
Commit a884cba4 authored by Art4's avatar Art4
Browse files

CS

parent 0c38e29d
Branches
Tags v3.8.2
No related merge requests found
<?php
// use Composer if possible
$composer_path = __DIR__ . '/../vendor/autoload.php';
if (file_exists($composer_path))
{
include $composer_path;
$composerPath = __DIR__.'/../vendor/autoload.php';
if (file_exists($composerPath)) {
include $composerPath;
return;
}
/**
/*
* PSR-4 implementation for Redmine
*
* @param string $class The fully-qualified class name.
......@@ -19,16 +17,14 @@ if (file_exists($composer_path))
spl_autoload_register(function ($class) {
// project-specific namespace prefix and base directory with trailing /
$namespace_map = [
'Redmine\\' => __DIR__ . '/Redmine/',
'Redmine\\Tests\\' => __DIR__ . '/../tests/',
'Redmine\\' => __DIR__.'/Redmine/',
'Redmine\\Tests\\' => __DIR__.'/../tests/',
];
foreach ($namespace_map as $prefix => $base_dir)
{
foreach ($namespace_map as $prefix => $base_dir) {
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0)
{
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
continue;
}
......@@ -39,11 +35,10 @@ spl_autoload_register(function ($class) {
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
$file = $base_dir.str_replace('\\', '/', $relative_class).'.php';
// if the file exists, require it
if (file_exists($file))
{
if (file_exists($file)) {
require $file;
break;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment