Skip to content

Commit 4f22933

Browse files
authored
Merge pull request #302 from patchlevel/add-stack-hydrator-config
allow to switch to experimentel stack hydrator
2 parents 133c0f5 + 7001d13 commit 4f22933

9 files changed

Lines changed: 277 additions & 54 deletions

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
],
2020
"require": {
2121
"php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0",
22-
"patchlevel/event-sourcing": "^3.18.0",
23-
"patchlevel/hydrator": "^1.18.0",
22+
"patchlevel/event-sourcing": "^3.19.1",
23+
"patchlevel/hydrator": "^1.21.2",
2424
"symfony/cache": "^6.4.0 || ^7.0.0 || ^8.0.0",
2525
"symfony/config": "^6.4.0 || ^7.0.0 || ^8.0.0",
2626
"symfony/console": "^6.4.1 || ^7.0.1 || ^8.0.0",

composer.lock

Lines changed: 36 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/DependencyInjection/Configuration.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Patchlevel\EventSourcingBundle\DependencyInjection;
66

77
use Patchlevel\EventSourcing\Repository\AggregateOutdated;
8+
use Patchlevel\Hydrator\Extension\Cryptography\Cipher\OpensslCipherKeyFactory;
89
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
910
use Symfony\Component\Config\Definition\ConfigurationInterface;
1011
use Throwable;
@@ -87,6 +88,17 @@
8788
* },
8889
* clock: array{freeze: ?string, service: ?string},
8990
* aggregate_handlers: array{enabled: bool, bus: string|null},
91+
* hydrator: array{
92+
* enabled: bool,
93+
* default_lazy: bool,
94+
* cryptography: array{
95+
* enabled: bool,
96+
* algorithm: string,
97+
* },
98+
* lifecycle: array{
99+
* enabled: bool,
100+
* },
101+
* },
90102
* }
91103
*/
92104
final class Configuration implements ConfigurationInterface
@@ -361,6 +373,25 @@ public function getConfigTreeBuilder(): TreeBuilder
361373
)
362374
->end()
363375

376+
->arrayNode('hydrator')
377+
->canBeEnabled()
378+
->addDefaultsIfNotSet()
379+
->children()
380+
->booleanNode('default_lazy')->defaultFalse()->end()
381+
->arrayNode('cryptography')
382+
->canBeEnabled()
383+
->addDefaultsIfNotSet()
384+
->children()
385+
->scalarNode('algorithm')->defaultValue(OpensslCipherKeyFactory::DEFAULT_METHOD)->end()
386+
->end()
387+
->end()
388+
->arrayNode('lifecycle')
389+
->canBeEnabled()
390+
->addDefaultsIfNotSet()
391+
->end()
392+
->end()
393+
->end()
394+
364395
->end();
365396
// @codingStandardsIgnoreEnd
366397

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Patchlevel\EventSourcingBundle\DependencyInjection;
6+
7+
use Patchlevel\Hydrator\StackHydratorBuilder;
8+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
9+
use Symfony\Component\DependencyInjection\ContainerBuilder;
10+
use Symfony\Component\DependencyInjection\Reference;
11+
12+
use function array_keys;
13+
14+
/** @internal */
15+
final class HydratorCompilerPass implements CompilerPassInterface
16+
{
17+
public function process(ContainerBuilder $container): void
18+
{
19+
if (!$container->has(StackHydratorBuilder::class)) {
20+
return;
21+
}
22+
23+
$builder = $container->getDefinition(StackHydratorBuilder::class);
24+
$extensions = $container->findTaggedServiceIds('event_sourcing.hydrator.extension');
25+
26+
foreach (array_keys($extensions) as $subscriberServiceName) {
27+
$builder->addMethodCall('useExtension', [new Reference($subscriberServiceName)]);
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)