Update ExtensionCompilerPass.php

This commit is contained in:
Bob den Otter
2020-07-20 10:26:37 +02:00
parent e74cbcd249
commit f674a9160d
+13 -5
View File
@@ -30,7 +30,7 @@ class ExtensionCompilerPass implements CompilerPassInterface
/* @see ExtensionRegistry::addCompilerPass() */
$registry->addMethodCall('addCompilerPass', [$packages]);
// Rebuild our own `services_bolt.yml` file.
// Rebuild our own `packages/bolt.yaml` file.
$this->buildServices($packages);
}
@@ -57,7 +57,7 @@ class ExtensionCompilerPass implements CompilerPassInterface
$yaml = "# This file is auto-generated by Bolt. Do not modify.\n\n";
$yaml .= Yaml::dump($services, 3);
$filename = $this->projectDir . '/config/services_bolt.yaml';
$filename = $this->projectDir . '/config/packages/bolt.yaml';
file_put_contents($filename, $yaml);
}
@@ -70,11 +70,11 @@ class ExtensionCompilerPass implements CompilerPassInterface
$reflection = new \ReflectionClass($package);
$namespace = Str::removeLast($reflection->getName(), Str::splitLast($reflection->getName(), '\\'));
$path = Path::makeRelative(dirname($reflection->getFileName()), $this->projectDir . '/foo');
$path = $this->getRelativePath($package);
return [$namespace, [
'resource' => $path . '/*',
'exclude' => $path . '/{Entity,Exception,Exclude}',
'exclude' => $path . '/{Entity,Exception}',
]];
}
@@ -93,4 +93,12 @@ class ExtensionCompilerPass implements CompilerPassInterface
return array_unique($packages);
}
}
private function getRelativePath(string $package): string
{
$reflection = new \ReflectionClass($package);
// We add the `/foo/bar` to make the path start with `../../`
return Path::makeRelative(dirname($reflection->getFileName()), $this->projectDir . '/foo/bar');
}
}