35 $factoriesOutput = [];
36 foreach (
$files as $file) {
37 $dom = new \DOMDocument();
39 $xpath = new \DOMXPath($dom);
40 $xpath->registerNamespace(
"php",
"http://php.net/xpath");
41 $xpath->registerPhpFunctions(
'preg_match');
42 $virtualTypeQuery =
"//virtualType/@name";
44 foreach ($xpath->query($virtualTypeQuery) as $virtualNode) {
45 $virtualTypes[] = $virtualNode->nodeValue;
48 $regex =
'/^(.*)\\\(.*)Proxy$/';
49 $query =
"/config/preference[ php:functionString('preg_match', '{$regex}', @type) > 0]/@type | " .
50 "//argument[@xsi:type='object' and php:functionString('preg_match', '{$regex}', text()) > 0] |" .
51 "//item[@xsi:type='object' and php:functionString('preg_match', '{$regex}', text()) > 0] |" .
52 "/config/virtualType[ php:functionString('preg_match', '{$regex}', @type) > 0]/@type";
54 foreach ($xpath->query(
$query) as $node) {
58 $factoriesOutput = array_merge($factoriesOutput, $this->scanFactories($xpath));
62 $factoriesOutput = array_unique($factoriesOutput);
63 $factoriesOutput = array_diff($factoriesOutput, $virtualTypes);
73 private function scanFactories(\DOMXPath $domXpath)
76 $regex =
'/^(.*)Factory$/';
77 $query =
"//argument[@xsi:type='object' and php:functionString('preg_match', '{$regex}', text()) > 0] |" .
78 "//item[@xsi:type='object' and php:functionString('preg_match', '{$regex}', text()) > 0]";
79 foreach ($domXpath->query(
$query) as $node) {
94 $entitySuffix =
'\\' . ucfirst(ProxyGenerator::ENTITY_TYPE);
95 $filteredEntities = [];
97 $entityName = substr(
$className, -strlen($entitySuffix)) === $entitySuffix
98 ? substr(
$className, 0, -strlen($entitySuffix))
100 $isClassExists =
false;
103 }
catch (\RuntimeException $e) {
105 if (
false === $isClassExists) {
106 if (
class_exists($entityName) || interface_exists($entityName)) {
112 'Invalid proxy class for ' . substr(
$className, 0, -5)
117 return $filteredEntities;
collectEntities(array $files)
_filterEntities(array $output)
__construct(\Magento\Setup\Module\Di\Compiler\Log\Log $log)
foreach($appDirs as $dir) $files