Skip to content

Commit c6eb87d

Browse files
committed
Beta of query bundle is ready
1 parent a718d4d commit c6eb87d

File tree

9 files changed

+30
-25
lines changed

9 files changed

+30
-25
lines changed

src/RunOpenCode/Bundle/QueryBundle/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"symfony/dependency-injection": "^7.0",
1717
"symfony/finder": "^7.0",
1818
"symfony/http-kernel": "^7.0",
19-
"twig/twig": "^3.0",
20-
"psr/container": "^2.0"
19+
"twig/twig": "^3.0"
2120
},
2221
"autoload": {
2322
"psr-4": {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
->addDefaultsIfNotSet()
1212
->children()
1313
->scalarNode('cache_pool')
14-
->defaultValue('app.cache')
14+
->defaultValue('cache.app')
1515
->info(<<<INFO
16-
Cache pool to use for cache middleware. By default `app.cache` is used. If `NULL` is provided, middleware will be still
16+
Cache pool to use for cache middleware. By default `cache.app` is used. If `NULL` is provided, middleware will be still
1717
registered, but `Symfony\Component\Cache\Adapter\NullAdapter` will be used (no caching).
1818
INFO)
1919
->end()

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@
1515
->addDefaultsIfNotSet()
1616
->children()
1717
->arrayNode('stack')
18-
->addDefaultsIfNotSet()
1918
->defaultValue([
2019
'cache',
2120
'parser',
2221
'executor',
2322
])
24-
->scalarPrototype()
23+
->scalarPrototype()->end()
2524
->end()
2625
->arrayNode('replica')
2726
->useAttributeAsKey('connection')

src/RunOpenCode/Bundle/QueryBundle/config/services/executor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
$configurator
1919
->set(AdapterRegistry::class)
20-
->arg('$executors', tagged_iterator('runopencode.query.adapter'));
20+
->arg('$adapters', tagged_iterator('runopencode.query.adapter'));
2121

2222
$configurator
2323
->set(MiddlewareRegistry::class);
@@ -31,8 +31,8 @@
3131

3232
$configurator
3333
->set(Executor::class)
34-
->arg('$middlewares', MiddlewareRegistry::class)
35-
->arg('$adapters', AdapterRegistry::class);
34+
->arg('$middlewares', service(MiddlewareRegistry::class))
35+
->arg('$adapters', service(AdapterRegistry::class));
3636

3737
$configurator
3838
->alias(ExecutorInterface::class, Executor::class);

src/RunOpenCode/Bundle/QueryBundle/config/services/twig.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
declare(strict_types=1);
44

5-
use Psr\Container\ContainerInterface;
65
use RunOpenCode\Bundle\QueryBundle\CacheWarmer\TwigCacheWarmer;
76
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
87
use Twig\Environment;
@@ -30,6 +29,6 @@
3029

3130
$configurator
3231
->set(TwigCacheWarmer::class)
33-
->arg('$container', service(ContainerInterface::class))
32+
->arg('$container', service('service_container'))
3433
->tag('kernel.cache_warmer');
3534
};

src/RunOpenCode/Bundle/QueryBundle/src/CacheWarmer/TwigCacheWarmer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array
3737
/** @var Environment $twig */
3838
$twig = $this->container->get('runopencode.query.twig');
3939

40+
// TODO -> cache replacement is a must!
4041
if ($twig->getCache() instanceof NullCache) {
4142
return [];
4243
}

src/RunOpenCode/Bundle/QueryBundle/src/DependencyInjection/CompilerPass/ConfigureMiddlewareStack.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,15 @@ private function getTaggedMiddlewares(ContainerBuilder $container): iterable
5555
$tagged = $container->findTaggedServiceIds('runopencode.query.middleware');
5656

5757
/**
58-
* @var array{ alias?: non-empty-string } $attributes
59-
* @var non-empty-string $id
58+
* @var list<array{ alias?: non-empty-string }> $attributes
59+
* @var non-empty-string $id
6060
*/
6161
foreach ($tagged as $id => $attributes) {
62-
if (isset($attributes['alias'])) {
63-
yield $attributes['alias'] => new Reference($id);
64-
continue;
62+
foreach ($attributes as $attribute) {
63+
if (isset($attribute['alias'])) {
64+
yield $attribute['alias'] => new Reference($id);
65+
continue 2;
66+
}
6567
}
6668

6769
yield $id => new Reference($id);

src/RunOpenCode/Bundle/QueryBundle/src/DependencyInjection/CompilerPass/ConfigureTwigLoader.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ public function process(ContainerBuilder $container): void
2828

2929
\assert(\is_string($projectDir));
3030

31-
$loader->addMethodCall('addPath', [$defaultPath, FilesystemLoader::MAIN_NAMESPACE]);
31+
/** @var non-empty-string $defaultPath */
32+
if (\is_dir($defaultPath)) {
33+
$loader->addMethodCall('addPath', [$defaultPath, FilesystemLoader::MAIN_NAMESPACE]);
34+
}
35+
36+
$container->addResource(new FileExistenceResource($defaultPath));
3237

3338
/** @var array<string, string|null> $paths */
3439
foreach ($paths as $path => $namespace) {

src/RunOpenCode/Bundle/QueryBundle/src/DependencyInjection/CompilerPass/RegisterDbalAdapters.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ public function process(ContainerBuilder $container): void
2121
return;
2222
}
2323

24-
/** @var list<non-empty-string> $connections */
24+
/** @var array<non-empty-string, non-empty-string> $connections */
2525
$connections = $container->getParameter('doctrine.connections');
26-
$default = $container->getParameter('doctrine.default_connection');
27-
$sorted = [
28-
$default,
29-
\array_filter($connections, static fn(string $connection): bool => $connection !== $default),
30-
];
3126

3227
/** @var non-empty-string $connection */
33-
foreach ($sorted as $connection) {
28+
foreach ($connections as $alias => $connection) {
3429
$definition = new Definition(Adapter::class, [
35-
$connection,
30+
$alias,
3631
new Reference($connection),
3732
]);
3833

3934
$definition->addTag('runopencode.query.adapter');
35+
36+
$container->setDefinition(
37+
\sprintf('runopencode.query.adapter.%s', $alias),
38+
$definition,
39+
);
4040
}
4141
}
4242
}

0 commit comments

Comments
 (0)