forked from contao-community-alliance/dc-general
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoload-validation-hack.php
46 lines (42 loc) · 1.63 KB
/
autoload-validation-hack.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
<?php
/**
* This file is part of contao-community-alliance/dc-general.
*
* (c) 2013-2015 Contao Community Alliance.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* This project is provided in good faith and hope to be usable by anyone.
*
* @package contao-community-alliance/dc-general
* @author Christian Schiffler <[email protected]>
* @copyright 2013-2015 Contao Community Alliance.
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0
* @filesource
*/
use PhpCodeQuality\AutoloadValidation\ClassLoader\EnumeratingClassLoader;
use PhpCodeQuality\AutoloadValidation\Exception\ParentClassNotFoundException;
// This is the hack to mimic the Contao auto loader.
spl_autoload_register(
function ($class) {
if (in_array($class, ['listable', 'editable', 'executable', 'uploadable'])) {
$reflection = new ReflectionClass(\Contao\CoreBundle\ContaoCoreBundle::class);
require_once dirname($reflection->getFileName()) . '/Resources/contao/helper/interface.php';
return true;
}
if (substr($class, 0, 7) === 'Contao\\') {
return null;
}
try {
spl_autoload_call('Contao\\' . $class);
} catch (ParentClassNotFoundException $exception) {
return null;
}
if (EnumeratingClassLoader::isLoaded('Contao\\' . $class) && !EnumeratingClassLoader::isLoaded($class)) {
class_alias('Contao\\' . $class, $class);
return true;
}
return null;
}
);