/
bootstrap.php
51 lines (38 loc) · 1.44 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/*
* Copyright (c) 2021 Heimrich & Hannot GmbH
*
* @license LGPL-3.0-or-later
*/
error_reporting(E_ALL);
$include = function ($file) {
return file_exists($file) ? include $file : false;
};
// PhpStorm fix (see https://www.drupal.org/node/2597814)
if (!defined('PHPUNIT_COMPOSER_INSTALL')) {
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/../vendor/autoload.php');
}
if (false === ($loader = $include(__DIR__.'/../vendor/autoload.php'))
&& false === ($loader = $include(__DIR__.'/../../../autoload.php'))
&& false === ($loader = $include(dirname(dirname(getenv('PWD'))).'/autoload.php'))) {
echo 'You must set up the project dependencies, run the following commands:'.PHP_EOL.'curl -sS https://getcomposer.org/installer | php'.PHP_EOL.'php composer.phar install'.PHP_EOL;
exit(1);
}
// Handle classes in the global namespace
$legacyLoader = function ($class) {
if (class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false)) {
return;
}
if (false !== strpos($class, '\\') && 0 !== strncmp($class, 'Contao\\', 7)) {
return;
}
if (0 === strncmp($class, 'Contao\\', 7)) {
$class = substr($class, 7);
}
$namespaced = 'Contao\\'.$class;
if (class_exists($namespaced) || interface_exists($namespaced) || trait_exists($namespaced)) {
class_alias($namespaced, $class);
}
};
spl_autoload_register($legacyLoader, true, true);
return $loader;