Skip to content

Commit 16cf554

Browse files
committed
add an option to disable cache
1 parent 39aa707 commit 16cf554

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

src/BuildContext.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class BuildContext
1515
private $htmlOutputDir;
1616
private $jsonOutputDir;
1717
private $parseSubPath;
18+
private $disableCache = false;
1819

1920
public function __construct(
2021
string $basePath,
@@ -30,12 +31,13 @@ public function __construct(
3031
$this->symfonyDocUrl = $symfonyDocUrl;
3132
}
3233

33-
public function initializeRuntimeConfig(string $sourceDir, string $htmlOutputDir, ?string $jsonOutputDir = null, ?string $parseSubPath = null)
34+
public function initializeRuntimeConfig(string $sourceDir, string $htmlOutputDir, ?string $jsonOutputDir = null, ?string $parseSubPath = null, ?bool $disableCache = false)
3435
{
3536
$this->sourceDir = $sourceDir;
3637
$this->htmlOutputDir = $htmlOutputDir;
3738
$this->jsonOutputDir = $jsonOutputDir;
3839
$this->parseSubPath = $parseSubPath;
40+
$this->disableCache = $disableCache;
3941
$this->runtimeInitialized = true;
4042
}
4143

@@ -92,6 +94,13 @@ public function getParseSubPath(): ?string
9294
return $this->parseSubPath;
9395
}
9496

97+
public function getDisableCache(): bool
98+
{
99+
$this->checkThatRuntimeConfigIsInitialized();
100+
101+
return $this->disableCache;
102+
}
103+
95104
private function checkThatRuntimeConfigIsInitialized()
96105
{
97106
if (false === $this->runtimeInitialized) {

src/Command/BuildDocsCommand.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ protected function configure()
4949
InputOption::VALUE_OPTIONAL,
5050
'Parse only given sub directory and combine it into a single file (directory relative from source-dir)',
5151
''
52+
)
53+
->addOption(
54+
'disable-cache',
55+
null,
56+
InputOption::VALUE_NONE,
57+
'If provided, caching meta will be disabled'
5258
);
5359
}
5460

src/Command/CommandInitializerTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ private function doInitialize(InputInterface $input, OutputInterface $output, st
4646
$sourceDir,
4747
$this->initializeHtmlOutputDir($this->filesystem, $outputDir),
4848
$this->initializeJsonOutputDir($outputDir),
49-
$this->initializeParseSubPath($input, $sourceDir)
49+
$this->initializeParseSubPath($input, $sourceDir),
50+
(bool) $input->getOption('disable-cache')
5051
);
5152

5253
$this->builder = new Builder(

src/KernelFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public static function createKernel(BuildContext $buildContext, ?UrlChecker $url
1919
$configuration->setCustomTemplateDirs([sprintf('%s/src/Templates', $buildContext->getBasePath())]);
2020
$configuration->setCacheDir(sprintf('%s/var/cache', $buildContext->getBasePath()));
2121

22+
if ($buildContext->getDisableCache()) {
23+
$configuration->setUseCachedMetas(false);
24+
}
25+
2226
$configuration->addFormat(
2327
new SymfonyHTMLFormat(
2428
$configuration->getTemplateRenderer(),

0 commit comments

Comments
 (0)