Skip to content

Commit 0fac944

Browse files
author
Jeremiah VALERIE
committed
Merge branch '0.10' into 0.11
2 parents 70600bf + 942286a commit 0fac944

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

CacheWarmer/CompileCacheWarmer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ public function isOptional()
2828
*/
2929
public function warmUp($cacheDir)
3030
{
31+
// use warm up cache dir if type generator cache dir not already explicitly declare
32+
$baseCacheDir = $this->typeGenerator->getBaseCacheDir();
33+
if (null === $this->typeGenerator->getCacheDir(false)) {
34+
$this->typeGenerator->setBaseCacheDir($cacheDir);
35+
}
3136
$this->typeGenerator->compile(TypeGenerator::MODE_WRITE | TypeGenerator::MODE_OVERRIDE);
37+
$this->typeGenerator->setBaseCacheDir($baseCacheDir);
3238
}
3339
}

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private function definitionsSection()
111111
->children()
112112
->variableNode('default_resolver')->defaultValue([Resolver::class, 'defaultResolveFn'])->end()
113113
->scalarNode('class_namespace')->defaultValue('Overblog\\GraphQLBundle\\__DEFINITIONS__')->end()
114-
->scalarNode('cache_dir')->defaultValue($this->cacheDir.'/overblog/graphql-bundle/__definitions__')->end()
114+
->scalarNode('cache_dir')->defaultNull()->end()
115115
->booleanNode('use_classloader_listener')->defaultTrue()->end()
116116
->booleanNode('auto_compile')->defaultTrue()->end()
117117
->booleanNode('show_debug_info')->info('Show some performance stats in extensions')->defaultFalse()->end()

Generator/TypeGenerator.php

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class TypeGenerator extends BaseTypeGenerator
2323

2424
private $useClassMap;
2525

26+
private $baseCacheDir;
27+
2628
private static $classMapLoaded = false;
2729

2830
public function __construct(
@@ -31,25 +33,50 @@ public function __construct(
3133
$cacheDir,
3234
array $configs,
3335
$useClassMap = true,
34-
callable $configProcessor = null)
36+
callable $configProcessor = null,
37+
$baseCacheDir = null
38+
)
3539
{
3640
$this->setCacheDir($cacheDir);
3741
$this->configProcessor = null === $configProcessor ? static::DEFAULT_CONFIG_PROCESSOR : $configProcessor;
3842
$this->configs = $configs;
3943
$this->useClassMap = $useClassMap;
44+
$this->baseCacheDir = $baseCacheDir;
45+
4046
parent::__construct($classNamespace, $skeletonDirs);
4147
}
4248

4349
/**
44-
* @return string
50+
* @return string|null
51+
*/
52+
public function getBaseCacheDir()
53+
{
54+
return $this->baseCacheDir;
55+
}
56+
57+
/**
58+
* @param string|null $baseCacheDir
4559
*/
46-
public function getCacheDir()
60+
public function setBaseCacheDir($baseCacheDir)
4761
{
48-
return $this->cacheDir;
62+
$this->baseCacheDir = $baseCacheDir;
63+
}
64+
65+
/**
66+
* @return string|null
67+
*/
68+
public function getCacheDir(/*bool $useDefault = true*/)
69+
{
70+
$useDefault = func_num_args() > 0 ? func_get_arg(0) : true;
71+
if ($useDefault) {
72+
return $this->cacheDir ?: $this->baseCacheDir.'/overblog/graphql-bundle/__definitions__';
73+
} else {
74+
return $this->cacheDir;
75+
}
4976
}
5077

5178
/**
52-
* @param string $cacheDir
79+
* @param string|null $cacheDir
5380
*
5481
* @return $this
5582
*/

Resources/config/services.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ services:
8686
- "%overblog_graphql.cache_dir%"
8787
- "%overblog_graphql_types.config%"
8888
- "%overblog_graphql.use_classloader_listener%"
89+
- ~
90+
- "%kernel.cache_dir%"
8991
calls:
9092
- ['addUseStatement', ['Overblog\GraphQLBundle\Definition\ConfigProcessor']]
9193
- ['addUseStatement', ['Overblog\GraphQLBundle\Definition\LazyConfig']]

0 commit comments

Comments
 (0)