Skip to content

Commit 0c41ffc

Browse files
authored
Merge pull request #271 from patchlevel/upgrade-to-4.0
upgrade event sourcing 4.0
2 parents 587e5a5 + 498b2e3 commit 0c41ffc

14 files changed

+44
-89
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
],
2020
"require": {
2121
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
22-
"patchlevel/event-sourcing": "^3.12.0",
22+
"patchlevel/event-sourcing": "4.0.x-dev",
2323
"symfony/cache": "^6.4.0|^7.0.0",
2424
"symfony/config": "^6.4.0|^7.0.0",
2525
"symfony/console": "^6.4.1|^7.0.1",

composer.lock

Lines changed: 8 additions & 7 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public function getConfigTreeBuilder(): TreeBuilder
105105
->addDefaultsIfNotSet()
106106
->children()
107107
->enumNode('type')
108-
->values(['dbal_aggregate', 'dbal_stream', 'in_memory', 'custom'])
109-
->defaultValue('dbal_aggregate')
108+
->values(['dbal_stream', 'in_memory', 'custom'])
109+
->defaultValue('dbal_stream')
110110
->end()
111111
->scalarNode('service')->defaultNull()->end()
112112
->booleanNode('merge_orm_schema')->defaultFalse()->end()
@@ -117,7 +117,7 @@ public function getConfigTreeBuilder(): TreeBuilder
117117
->addDefaultsIfNotSet()
118118
->children()
119119
->enumNode('type')
120-
->values(['dbal_aggregate', 'dbal_stream', 'in_memory', 'custom'])
120+
->values(['dbal_stream', 'in_memory', 'custom'])
121121
->end()
122122
->scalarNode('service')->defaultNull()->end()
123123
->arrayNode('options')->variablePrototype()->end()->end()

src/DependencyInjection/PatchlevelEventSourcingExtension.php

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@
9090
use Patchlevel\EventSourcing\Snapshot\Adapter\Psr6SnapshotAdapter;
9191
use Patchlevel\EventSourcing\Snapshot\DefaultSnapshotStore;
9292
use Patchlevel\EventSourcing\Snapshot\SnapshotStore;
93-
use Patchlevel\EventSourcing\Store\DoctrineDbalStore;
9493
use Patchlevel\EventSourcing\Store\InMemoryStore;
95-
use Patchlevel\EventSourcing\Store\ReadOnlyStore;
9694
use Patchlevel\EventSourcing\Store\Store;
9795
use Patchlevel\EventSourcing\Store\StreamDoctrineDbalStore;
9896
use Patchlevel\EventSourcing\Store\StreamReadOnlyStore;
@@ -128,7 +126,7 @@
128126
use Patchlevel\EventSourcingBundle\RequestListener\SubscriptionRebuildAfterFileChangeListener;
129127
use Patchlevel\EventSourcingBundle\Subscription\ResetServicesListener;
130128
use Patchlevel\EventSourcingBundle\Subscription\StaticInMemorySubscriptionStoreFactory;
131-
use Patchlevel\EventSourcingBundle\ValueResolver\AggregateRootIdValueResolver;
129+
use Patchlevel\EventSourcingBundle\ValueResolver\IdentifierValueResolver;
132130
use Patchlevel\Hydrator\Cryptography\Cipher\Cipher;
133131
use Patchlevel\Hydrator\Cryptography\Cipher\CipherKeyFactory;
134132
use Patchlevel\Hydrator\Cryptography\Cipher\OpensslCipher;
@@ -709,29 +707,6 @@ private function configureStore(array $config, ContainerBuilder $container): voi
709707
return;
710708
}
711709

712-
if ($config['store']['type'] === 'dbal_aggregate') {
713-
$container->register(DoctrineDbalStore::class)
714-
->setArguments([
715-
new Reference('event_sourcing.dbal_connection'),
716-
new Reference(EventSerializer::class),
717-
new Reference(HeadersSerializer::class),
718-
$config['store']['options'],
719-
])
720-
->addTag('event_sourcing.doctrine_schema_configurator');
721-
722-
$container->setAlias(Store::class, DoctrineDbalStore::class);
723-
724-
if ($config['store']['read_only']) {
725-
$container->register(ReadOnlyStore::class)
726-
->setDecoratedService(Store::class)
727-
->setArguments([
728-
new Reference('.inner'),
729-
]);
730-
}
731-
732-
return;
733-
}
734-
735710
if ($config['store']['type'] === 'dbal_stream') {
736711
$container->register(StreamDoctrineDbalStore::class)
737712
->setArguments([
@@ -795,19 +770,6 @@ private function configureStoreMigration(array $config, ContainerBuilder $contai
795770
return;
796771
}
797772

798-
if ($config['store']['migrate_to_new_store']['type'] === 'dbal_aggregate') {
799-
$container->register($id, DoctrineDbalStore::class)
800-
->setArguments([
801-
new Reference('event_sourcing.dbal_connection'),
802-
new Reference(EventSerializer::class),
803-
new Reference(HeadersSerializer::class),
804-
$config['store']['migrate_to_new_store']['options'],
805-
])
806-
->addTag('event_sourcing.doctrine_schema_configurator');
807-
808-
return;
809-
}
810-
811773
if ($config['store']['migrate_to_new_store']['type'] === 'dbal_stream') {
812774
$container->register($id, StreamDoctrineDbalStore::class)
813775
->setArguments([
@@ -1175,7 +1137,7 @@ private function configureCryptography(array $config, ContainerBuilder $containe
11751137

11761138
private function configureValueResolver(ContainerBuilder $container): void
11771139
{
1178-
$container->register(AggregateRootIdValueResolver::class)
1140+
$container->register(IdentifierValueResolver::class)
11791141
->addTag('controller.argument_value_resolver', ['priority' => 200]);
11801142
}
11811143

src/ValueResolver/AggregateRootIdValueResolver.php renamed to src/ValueResolver/IdentifierValueResolver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@
44

55
namespace Patchlevel\EventSourcingBundle\ValueResolver;
66

7-
use Patchlevel\EventSourcing\Aggregate\AggregateRootId;
7+
use Patchlevel\EventSourcing\Identifier\Identifier;
88
use Symfony\Component\HttpFoundation\Request;
99
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
1010
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
1111

1212
use function is_a;
1313
use function is_string;
1414

15-
final class AggregateRootIdValueResolver implements ValueResolverInterface
15+
final class IdentifierValueResolver implements ValueResolverInterface
1616
{
17-
/** @return iterable<AggregateRootId> */
17+
/** @return iterable<Identifier> */
1818
public function resolve(Request $request, ArgumentMetadata $argument): iterable
1919
{
2020
$argumentType = $argument->getType();
2121

22-
if ($argumentType === null || !is_a($argumentType, AggregateRootId::class, true)) {
22+
if ($argumentType === null || !is_a($argumentType, Identifier::class, true)) {
2323
return [];
2424
}
2525

tests/Fixtures/CreateProfile.php

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

33
namespace Patchlevel\EventSourcingBundle\Tests\Fixtures;
44

5-
use Patchlevel\EventSourcing\Aggregate\CustomId;
5+
use Patchlevel\EventSourcing\Identifier\CustomId;
66

77
class CreateProfile
88
{

tests/Fixtures/Profile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Patchlevel\EventSourcingBundle\Tests\Fixtures;
44

55
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
6-
use Patchlevel\EventSourcing\Aggregate\CustomId;
6+
use Patchlevel\EventSourcing\Identifier\CustomId;
77
use Patchlevel\EventSourcing\Attribute\Aggregate;
88
use Patchlevel\EventSourcing\Attribute\Apply;
99
use Patchlevel\EventSourcing\Attribute\Handle;

tests/Fixtures/ProfileCreated.php

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

33
namespace Patchlevel\EventSourcingBundle\Tests\Fixtures;
44

5-
use Patchlevel\EventSourcing\Aggregate\CustomId;
5+
use Patchlevel\EventSourcing\Identifier\CustomId;
66
use Patchlevel\EventSourcing\Attribute\Event;
77
use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer;
88

tests/Fixtures/SnapshotableProfile.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Patchlevel\EventSourcingBundle\Tests\Fixtures;
44

55
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
6-
use Patchlevel\EventSourcing\Aggregate\CustomId;
6+
use Patchlevel\EventSourcing\Identifier\CustomId;
77
use Patchlevel\EventSourcing\Attribute\Aggregate;
88
use Patchlevel\EventSourcing\Attribute\Apply;
99
use Patchlevel\EventSourcing\Attribute\Id;

tests/Unit/CommandBus/SymfonyCommandtBusTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Patchlevel\EventSourcingBundle\Tests\Unit\CommandBus;
66

7-
use Patchlevel\EventSourcing\Aggregate\CustomId;
7+
use Patchlevel\EventSourcing\Identifier\CustomId;
88
use Patchlevel\EventSourcingBundle\CommandBus\SymfonyCommandBus;
99
use Patchlevel\EventSourcingBundle\Tests\Fixtures\CreateProfile;
1010
use PHPUnit\Framework\TestCase;

0 commit comments

Comments
 (0)