/**
* @param string $path
* @return array
*/
protected function getBundlesFromPath($path)
{
$bundles = [];
if ($this->localFilesystem->has($path)) {
$finder = new Finder();
$finder->files()->name('*Bundle.php')->notPath('/\\/Tests\\//')->notPath('/\\/Test\\//')->notPath('Tests/Integration/skeletion')->notPath('Jarves/vendor')->in($this->rootDir . '/../' . $path);
/** @var \Symfony\Component\Finder\SplFileInfo $file */
foreach ($finder as $file) {
$file = $file->getRealPath();
$content = file_get_contents($file);
preg_match('/^\\s*\\t*class ([a-z0-9_]+)/mi', $content, $className);
if (isset($className[1]) && $className[1]) {
preg_match('/\\s*\\t*namespace ([a-zA-Z0-9_\\\\]+)/', $content, $namespace);
$class = (isset($namespace[1]) ? $namespace[1] . '\\' : '') . $className[1];
if ('Bundle' === $className[1]) {
continue;
}
if (class_exists($class)) {
$reflection = new \ReflectionClass($class);
$interfaces = $reflection->getInterfaceNames();
if (in_array('Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface', $interfaces)) {
$bundles[] = $class;
}
}
}
}
}
return $bundles;
}