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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Framework\Autoload;
use Composer\Autoload\ClassLoader;
/**
* Wrapper designed to insulate the autoloader class provided by Composer
*/
class ClassLoaderWrapper implements AutoloaderInterface
{
/**
* Using the autoloader class provided by Composer
*
* @var ClassLoader
*/
protected $autoloader;
/**
* @param ClassLoader $autoloader
*/
public function __construct(ClassLoader $autoloader)
{
$this->autoloader = $autoloader;
}
/**
* {@inheritdoc}
*/
public function addPsr4($nsPrefix, $paths, $prepend = false)
{
$this->autoloader->addPsr4($nsPrefix, $paths, $prepend);
}
/**
* {@inheritdoc}
*/
public function addPsr0($nsPrefix, $paths, $prepend = false)
{
$this->autoloader->add($nsPrefix, $paths, $prepend);
}
/**
* {@inheritdoc}
*/
public function setPsr0($nsPrefix, $paths)
{
$this->autoloader->set($nsPrefix, $paths);
}
/**
* {@inheritdoc}
*/
public function setPsr4($nsPrefix, $paths)
{
$this->autoloader->setPsr4($nsPrefix, $paths);
}
/**
* {@inheritdoc}
* @codeCoverageIgnore
*/
public function loadClass($className)
{
return $this->autoloader->loadClass($className) === true;
}
/**
* {@inheritdoc}
* @codeCoverageIgnore
*/
public function findFile($className)
{
/**
* Composer remembers that files don't exist even after they are generated. This clears the entry for
* $className so we can check the filesystem again for class existence.
*/
if ($className[0] === '\\') {
$className = substr($className, 1);
}
$this->autoloader->addClassMap([$className => null]);
return $this->autoloader->findFile($className);
}
}