Skip to content

Commit 6b72d28

Browse files
committed
Fixing bundle
1 parent 91e4609 commit 6b72d28

28 files changed

+930
-332
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"symfony/http-kernel": "^7.0",
2222
"symfony/process": "^7.3",
2323
"symfony/string": "^7.0",
24+
"thecodingmachine/safe": "^3.3",
2425
"twig/twig": "^3.0"
2526
},
2627
"require-dev": {

composer.lock

Lines changed: 140 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
6+
7+
return static function(DefinitionConfigurator $definition): void {
8+
// @phpstan-ignore-next-line
9+
$definition
10+
->rootNode()
11+
->addDefaultsIfNotSet()
12+
->children()
13+
->scalarNode('default_connection')
14+
->defaultNull()
15+
->info('Default connection name. If not provided, first registered adapter connection will be considered as default one.')
16+
->end()
17+
->scalarNode('default_path')
18+
->info('The default path used to load queries.')
19+
->defaultValue('%kernel.project_dir%/query')
20+
->end()
21+
->arrayNode('query_paths')
22+
->info('Additional paths where queries can be found.')
23+
->defaultValue([])
24+
->beforeNormalization()
25+
->ifArray()
26+
->then(static function(array $paths): array {
27+
$normalized = [];
28+
29+
/**
30+
* @var string|int $path
31+
* @var string $namespace
32+
*/
33+
foreach ($paths as $path => $namespace) {
34+
// path within the default namespace
35+
if (\ctype_digit((string) $path)) {
36+
$path = $namespace;
37+
$namespace = null;
38+
}
39+
40+
$normalized[$path] = $namespace;
41+
}
42+
43+
return $normalized;
44+
})
45+
->end()
46+
->prototype('variable')->end()
47+
->end()
48+
49+
->end();
50+
};

src/RunOpenCode/Bundle/QueryBundle/config/definition/cache.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/RunOpenCode/Bundle/QueryBundle/config/definition/middleware.php

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,27 @@
22

33
declare(strict_types=1);
44

5+
use Psr\Log\LogLevel;
56
use RunOpenCode\Component\Query\Replica\FallbackStrategy;
67
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
78

89
return static function(DefinitionConfigurator $definition): void {
10+
$assertCatchable = static function (?array $value): bool {
11+
if (null === $value) {
12+
return true;
13+
}
14+
15+
foreach ($value as $current) {
16+
if (\is_string($current) && \is_a($current, \Exception::class, true)) {
17+
continue;
18+
}
19+
20+
return false;
21+
}
22+
23+
return true;
24+
};
25+
926
// @phpstan-ignore-next-line
1027
$definition
1128
->rootNode()
@@ -18,7 +35,6 @@
1835
->defaultValue([
1936
'cache',
2037
'parser',
21-
'executor',
2238
])
2339
->scalarPrototype()->end()
2440
->end()
@@ -40,31 +56,52 @@
4056
->booleanNode('disabled')
4157
->defaultValue('%kernel.debug%')
4258
->end()
59+
->arrayNode('catch')
60+
->scalarPrototype()->end()
61+
->defaultValue(null)
62+
->validate()
63+
->ifFalse($assertCatchable)
64+
->thenInvalid('Replica middleware expects a list of full qualified class names which extends "\Exception" to catch.')
65+
->end()
66+
->end()
4367
->end()
4468
->end()
4569
->end()
4670
->arrayNode('retry')
4771
->scalarPrototype()->end()
4872
->defaultValue(null)
4973
->validate()
50-
->ifFalse(static function(?array $value): bool {
51-
if (null === $value) {
52-
return true;
53-
}
54-
55-
foreach ($value as $current) {
56-
if (\is_string($current) && \is_a($current, \Exception::class, true)) {
57-
continue;
58-
}
59-
60-
return false;
61-
}
62-
63-
return true;
64-
})
74+
->ifFalse($assertCatchable)
6575
->thenInvalid('Retry middleware expects a list of full qualified class names which extends "\Exception".')
6676
->end()
6777
->end()
78+
->arrayNode('slow')
79+
->addDefaultsIfNotSet()
80+
->children()
81+
->scalarNode('logger')
82+
->defaultNull()
83+
->end()
84+
->scalarNode('level')
85+
->defaultValue(LogLevel::ERROR)
86+
->end()
87+
->integerNode('threshold')
88+
->min(1)
89+
->defaultValue(30)
90+
->end()
91+
->booleanNode('always')
92+
->defaultFalse()
93+
->end()
94+
->end()
95+
->arrayNode('cache')
96+
->addDefaultsIfNotSet()
97+
->children()
98+
->scalarNode('cache_pool')
99+
->defaultValue('cache.app')
100+
->info('Cache pool to use for cache middleware. By default `cache.app` is used. If `NULL` is provided, middleware will be still registered, but `Symfony\Component\Cache\Adapter\NullAdapter` will be used (no caching). ')
101+
->end()
102+
->end()
103+
->end()
104+
->end()
68105
->end()
69106
->end();
70107
};

0 commit comments

Comments
 (0)