Skip to content

Commit

Permalink
support scan_cacheable #33
Browse files Browse the repository at this point in the history
  • Loading branch information
tw2066 committed Sep 5, 2024
1 parent b8a99de commit 56cfafa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Swagger/GenerateProxyClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Hyperf\ApiDocs\Ast\ResponseVisitor;
use Hyperf\ApiDocs\Exception\ApiDocsException;
use Hyperf\Di\Annotation\AnnotationCollector;
use Hyperf\DTO\DtoConfig;
use Hyperf\Support\Composer;
use PhpParser\NodeTraverser;
use PhpParser\ParserFactory;
Expand All @@ -24,6 +25,7 @@ class GenerateProxyClass
public function __construct(
protected SwaggerConfig $swaggerConfig,
protected SwaggerCommon $swaggerCommon,
protected DtoConfig $dtoConfig,
) {
$proxyDir = $this->swaggerConfig->getProxyDir();
if (file_exists($proxyDir) === false) {
Expand Down Expand Up @@ -107,7 +109,9 @@ protected function putContents($generateNamespaceClassName, $content): void
$outputDir = $this->swaggerConfig->getProxyDir();
$generateClassName = str_replace('\\', '_', $generateNamespaceClassName);
$filename = $outputDir . $generateClassName . '.dto.proxy.php';
file_put_contents($filename, $content);
if (! $this->dtoConfig->isScanCacheable()) {
file_put_contents($filename, $content);
}
$classLoader = Composer::getLoader();
$classLoader->addClassMap([$generateNamespaceClassName => $filename]);
}
Expand Down

0 comments on commit 56cfafa

Please sign in to comment.