[DI] fix generating preload file when cache_dir is outside project_dir
This commit is contained in:
parent
a19f91ad69
commit
02db8e1523
@ -309,7 +309,7 @@ EOF;
|
|||||||
$this->asFiles = false;
|
$this->asFiles = false;
|
||||||
|
|
||||||
if ($this->preload && null !== $autoloadFile = $this->getAutoloadFile()) {
|
if ($this->preload && null !== $autoloadFile = $this->getAutoloadFile()) {
|
||||||
$autoloadFile = substr($this->export($autoloadFile), 2, -1);
|
$autoloadFile = trim($this->export($autoloadFile), '()\\');
|
||||||
|
|
||||||
$code[$options['class'].'.preload.php'] = <<<EOF
|
$code[$options['class'].'.preload.php'] = <<<EOF
|
||||||
<?php
|
<?php
|
||||||
@ -2076,9 +2076,7 @@ EOF;
|
|||||||
|
|
||||||
private function getAutoloadFile(): ?string
|
private function getAutoloadFile(): ?string
|
||||||
{
|
{
|
||||||
if (null === $this->targetDirRegex) {
|
$file = null;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (spl_autoload_functions() as $autoloader) {
|
foreach (spl_autoload_functions() as $autoloader) {
|
||||||
if (!\is_array($autoloader)) {
|
if (!\is_array($autoloader)) {
|
||||||
@ -2097,14 +2095,14 @@ EOF;
|
|||||||
if (0 === strpos($class, 'ComposerAutoloaderInit') && $class::getLoader() === $autoloader[0]) {
|
if (0 === strpos($class, 'ComposerAutoloaderInit') && $class::getLoader() === $autoloader[0]) {
|
||||||
$file = \dirname((new \ReflectionClass($class))->getFileName(), 2).'/autoload.php';
|
$file = \dirname((new \ReflectionClass($class))->getFileName(), 2).'/autoload.php';
|
||||||
|
|
||||||
if (preg_match($this->targetDirRegex.'A', $file)) {
|
if (null !== $this->targetDirRegex && preg_match($this->targetDirRegex.'A', $file)) {
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return $file;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getClasses(Definition $definition): array
|
private function getClasses(Definition $definition): array
|
||||||
|
Reference in New Issue
Block a user