问题解决了!:-)
我的一个朋友有一个好主意来解决这个问题。实际上,这不是正确的解决方案,但这是解决此问题的唯一方法。
我们创建“api_index.yaml”
export_path: '/config/packages/api_doc.yaml'
import_paths:
- "@DomCoreBundle/Resources/config/api_doc/api_base_doc.yaml"
- "@DomCmsBundle/Resources/config/api_doc/static_page_path_doc.yaml"
- "@DomEntityBundle/Resources/config/api_doc/category_path_doc.yaml"
- "@DomCmsBundle/Resources/config/api_doc/carousel_path_doc.yaml"
- "@DomQuickLinkBundle/Resources/config/api_doc/quick_link_path_doc.yaml"
- "@DomUserBundle/Resources/config/api_doc/user_path_doc.yaml"
- "@DomUserBundle/Resources/config/api_doc/dealer_path_doc.yaml"
...
然后我们创建一个 Symfony 命令(脚本),它读取每个“import_paths”文件并将内容附加到“export_path”文件中。
$this->io = new SymfonyStyle($input, $output);
$path = $this->kernel->locateResource('@FaCoreBundle/Resources/config/api_index.yaml');
$paths = Yaml::parse(file_get_contents($path));
if (array_key_exists('import_paths', $paths)) {
$contentLength = $this->loadFilesByPath($input, $output, $paths);
if ($input->getOption('watch')) {
$contentLengthNew = [];
while (true) {
foreach ($paths['import_paths'] as $path) {
$ymlPath = $this->kernel->locateResource($path);
$contentLengthNew[$ymlPath] = md5((file_get_contents($ymlPath)));
}
if (!empty(array_diff($contentLength, $contentLengthNew)) || count($contentLength) != count($contentLengthNew)) {
$diff = array_diff($contentLengthNew, $contentLength);
if (!empty($diff)) {
$this->io->writeln(sprintf('<comment>%s</comment> <info>[file+]</info> %s', date('H:i:s'), current(array_keys($diff))));
}
$contentLength = $this->loadFilesByPath($input, $output, $paths);
}
sleep($input->getOption('period'));
}
}
}