Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"require": {
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
"patchlevel/event-sourcing": "^3.12.0",
"patchlevel/event-sourcing": "4.0.x-dev",
"symfony/cache": "^6.4.0|^7.0.0",
"symfony/config": "^6.4.0|^7.0.0",
"symfony/console": "^6.4.1|^7.0.1",
Expand Down
15 changes: 8 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public function getConfigTreeBuilder(): TreeBuilder
->addDefaultsIfNotSet()
->children()
->enumNode('type')
->values(['dbal_aggregate', 'dbal_stream', 'in_memory', 'custom'])
->defaultValue('dbal_aggregate')
->values(['dbal_stream', 'in_memory', 'custom'])
->defaultValue('dbal_stream')
->end()
->scalarNode('service')->defaultNull()->end()
->booleanNode('merge_orm_schema')->defaultFalse()->end()
Expand All @@ -117,7 +117,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->addDefaultsIfNotSet()
->children()
->enumNode('type')
->values(['dbal_aggregate', 'dbal_stream', 'in_memory', 'custom'])
->values(['dbal_stream', 'in_memory', 'custom'])
->end()
->scalarNode('service')->defaultNull()->end()
->arrayNode('options')->variablePrototype()->end()->end()
Expand Down
42 changes: 2 additions & 40 deletions src/DependencyInjection/PatchlevelEventSourcingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@
use Patchlevel\EventSourcing\Snapshot\Adapter\Psr6SnapshotAdapter;
use Patchlevel\EventSourcing\Snapshot\DefaultSnapshotStore;
use Patchlevel\EventSourcing\Snapshot\SnapshotStore;
use Patchlevel\EventSourcing\Store\DoctrineDbalStore;
use Patchlevel\EventSourcing\Store\InMemoryStore;
use Patchlevel\EventSourcing\Store\ReadOnlyStore;
use Patchlevel\EventSourcing\Store\Store;
use Patchlevel\EventSourcing\Store\StreamDoctrineDbalStore;
use Patchlevel\EventSourcing\Store\StreamReadOnlyStore;
Expand Down Expand Up @@ -128,7 +126,7 @@
use Patchlevel\EventSourcingBundle\RequestListener\SubscriptionRebuildAfterFileChangeListener;
use Patchlevel\EventSourcingBundle\Subscription\ResetServicesListener;
use Patchlevel\EventSourcingBundle\Subscription\StaticInMemorySubscriptionStoreFactory;
use Patchlevel\EventSourcingBundle\ValueResolver\AggregateRootIdValueResolver;
use Patchlevel\EventSourcingBundle\ValueResolver\IdentifierValueResolver;
use Patchlevel\Hydrator\Cryptography\Cipher\Cipher;
use Patchlevel\Hydrator\Cryptography\Cipher\CipherKeyFactory;
use Patchlevel\Hydrator\Cryptography\Cipher\OpensslCipher;
Expand Down Expand Up @@ -709,29 +707,6 @@ private function configureStore(array $config, ContainerBuilder $container): voi
return;
}

if ($config['store']['type'] === 'dbal_aggregate') {
$container->register(DoctrineDbalStore::class)
->setArguments([
new Reference('event_sourcing.dbal_connection'),
new Reference(EventSerializer::class),
new Reference(HeadersSerializer::class),
$config['store']['options'],
])
->addTag('event_sourcing.doctrine_schema_configurator');

$container->setAlias(Store::class, DoctrineDbalStore::class);

if ($config['store']['read_only']) {
$container->register(ReadOnlyStore::class)
->setDecoratedService(Store::class)
->setArguments([
new Reference('.inner'),
]);
}

return;
}

if ($config['store']['type'] === 'dbal_stream') {
$container->register(StreamDoctrineDbalStore::class)
->setArguments([
Expand Down Expand Up @@ -795,19 +770,6 @@ private function configureStoreMigration(array $config, ContainerBuilder $contai
return;
}

if ($config['store']['migrate_to_new_store']['type'] === 'dbal_aggregate') {
$container->register($id, DoctrineDbalStore::class)
->setArguments([
new Reference('event_sourcing.dbal_connection'),
new Reference(EventSerializer::class),
new Reference(HeadersSerializer::class),
$config['store']['migrate_to_new_store']['options'],
])
->addTag('event_sourcing.doctrine_schema_configurator');

return;
}

if ($config['store']['migrate_to_new_store']['type'] === 'dbal_stream') {
$container->register($id, StreamDoctrineDbalStore::class)
->setArguments([
Expand Down Expand Up @@ -1175,7 +1137,7 @@ private function configureCryptography(array $config, ContainerBuilder $containe

private function configureValueResolver(ContainerBuilder $container): void
{
$container->register(AggregateRootIdValueResolver::class)
$container->register(IdentifierValueResolver::class)
->addTag('controller.argument_value_resolver', ['priority' => 200]);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

namespace Patchlevel\EventSourcingBundle\ValueResolver;

use Patchlevel\EventSourcing\Aggregate\AggregateRootId;
use Patchlevel\EventSourcing\Identifier\Identifier;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;

use function is_a;
use function is_string;

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

if ($argumentType === null || !is_a($argumentType, AggregateRootId::class, true)) {
if ($argumentType === null || !is_a($argumentType, Identifier::class, true)) {
return [];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/CreateProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Patchlevel\EventSourcingBundle\Tests\Fixtures;

use Patchlevel\EventSourcing\Aggregate\CustomId;
use Patchlevel\EventSourcing\Identifier\CustomId;

class CreateProfile
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Patchlevel\EventSourcingBundle\Tests\Fixtures;

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\CustomId;
use Patchlevel\EventSourcing\Identifier\CustomId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Attribute\Handle;
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/ProfileCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Patchlevel\EventSourcingBundle\Tests\Fixtures;

use Patchlevel\EventSourcing\Aggregate\CustomId;
use Patchlevel\EventSourcing\Identifier\CustomId;
use Patchlevel\EventSourcing\Attribute\Event;
use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer;

Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/SnapshotableProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Patchlevel\EventSourcingBundle\Tests\Fixtures;

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\CustomId;
use Patchlevel\EventSourcing\Identifier\CustomId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Attribute\Id;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/CommandBus/SymfonyCommandtBusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Patchlevel\EventSourcingBundle\Tests\Unit\CommandBus;

use Patchlevel\EventSourcing\Aggregate\CustomId;
use Patchlevel\EventSourcing\Identifier\CustomId;
use Patchlevel\EventSourcingBundle\CommandBus\SymfonyCommandBus;
use Patchlevel\EventSourcingBundle\Tests\Fixtures\CreateProfile;
use PHPUnit\Framework\TestCase;
Expand Down
17 changes: 8 additions & 9 deletions tests/Unit/DataCollector/EventSourcingCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
namespace Patchlevel\EventSourcingBundle\Tests\Unit\DataCollector;

use DateTimeImmutable;
use Patchlevel\EventSourcing\Aggregate\AggregateHeader;
use Patchlevel\EventSourcing\Aggregate\CustomId;
use Patchlevel\EventSourcing\Identifier\CustomId;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AggregateRootRegistry;
use Patchlevel\EventSourcing\Metadata\Event\EventRegistry;
use Patchlevel\EventSourcing\Serializer\Encoder\Encoder;
use Patchlevel\EventSourcing\Serializer\EventSerializer;
use Patchlevel\EventSourcing\Serializer\SerializedEvent;
use Patchlevel\EventSourcing\Store\Header\PlayheadHeader;
use Patchlevel\EventSourcing\Store\Header\RecordedOnHeader;
use Patchlevel\EventSourcing\Store\Header\StreamNameHeader;
use Patchlevel\EventSourcingBundle\DataCollector\EventSourcingCollector;
use Patchlevel\EventSourcingBundle\DataCollector\MessageCollectorEventBus;
use Patchlevel\EventSourcingBundle\Tests\Fixtures\Profile;
Expand Down Expand Up @@ -41,12 +43,9 @@ public function testCollectData(): void
$event = new ProfileCreated(new CustomId('1'));

$message = Message::createWithHeaders($event, [
new AggregateHeader(
'profile',
'1',
1,
new DateTimeImmutable('2022-07-07T18:55:50+02:00'),
)
new StreamNameHeader('profile-1'),
new PlayheadHeader(1),
new RecordedOnHeader(new DateTimeImmutable('2022-07-07T18:55:50+02:00'))
]);

$eventSerializer = $this->prophesize(EventSerializer::class);
Expand Down Expand Up @@ -81,7 +80,7 @@ public function testCollectData(): void
self::assertEquals('profile.created', $message['event_name']);
self::assertInstanceOf(Data::class, $message['event']);
self::assertIsArray($message['headers']);
self::assertCount(1, $message['headers']);
self::assertCount(3, $message['headers']);
self::assertInstanceOf(Data::class, $message['headers'][0]);
}
}
2 changes: 1 addition & 1 deletion tests/Unit/EventBus/SymfonyEventBusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Patchlevel\EventSourcingBundle\Tests\Unit\EventBus;

use Patchlevel\EventSourcing\Aggregate\CustomId;
use Patchlevel\EventSourcing\Identifier\CustomId;
use Patchlevel\EventSourcing\Message\Message;
use Patchlevel\EventSourcingBundle\EventBus\SymfonyEventBus;
use Patchlevel\EventSourcingBundle\Tests\Fixtures\ProfileCreated;
Expand Down
17 changes: 5 additions & 12 deletions tests/Unit/PatchlevelEventSourcingBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use Patchlevel\EventSourcing\EventBus\DefaultEventBus;
use Patchlevel\EventSourcing\EventBus\EventBus;
use Patchlevel\EventSourcing\EventBus\Psr14EventBus;
use Patchlevel\EventSourcing\Message\Translator\AggregateToStreamHeaderTranslator;
use Patchlevel\EventSourcing\Message\Translator\ExcludeEventWithHeaderTranslator;
use Patchlevel\EventSourcing\Message\Translator\RecalculatePlayheadTranslator;
use Patchlevel\EventSourcing\Metadata\AggregateRoot\AggregateRootRegistry;
Expand All @@ -59,9 +58,7 @@
use Patchlevel\EventSourcing\Snapshot\DefaultSnapshotStore;
use Patchlevel\EventSourcing\Snapshot\SnapshotStore;
use Patchlevel\EventSourcing\Store\ArchivedHeader;
use Patchlevel\EventSourcing\Store\DoctrineDbalStore;
use Patchlevel\EventSourcing\Store\InMemoryStore;
use Patchlevel\EventSourcing\Store\ReadOnlyStore;
use Patchlevel\EventSourcing\Store\Store;
use Patchlevel\EventSourcing\Store\StreamDoctrineDbalStore;
use Patchlevel\EventSourcing\Store\StreamReadOnlyStore;
Expand Down Expand Up @@ -151,7 +148,7 @@ public function testMinimalConfig(): void
);

self::assertInstanceOf(Connection::class, $container->get('event_sourcing.dbal_connection'));
self::assertInstanceOf(DoctrineDbalStore::class, $container->get(Store::class));
self::assertInstanceOf(StreamDoctrineDbalStore::class, $container->get(Store::class));
self::assertInstanceOf(AggregateRootRegistry::class, $container->get(AggregateRootRegistry::class));
self::assertInstanceOf(DefaultRepositoryManager::class, $container->get(RepositoryManager::class));
self::assertInstanceOf(EventRegistry::class, $container->get(EventRegistry::class));
Expand Down Expand Up @@ -186,7 +183,7 @@ public function testConnectionService(): void
);

self::assertInstanceOf(Connection::class, $container->get('event_sourcing.dbal_connection'));
self::assertInstanceOf(DoctrineDbalStore::class, $container->get(Store::class));
self::assertInstanceOf(StreamDoctrineDbalStore::class, $container->get(Store::class));
}

public function testProjectionConnection(): void
Expand Down Expand Up @@ -321,7 +318,7 @@ public function testReadOnlyStore(): void
]
);

self::assertInstanceOf(ReadOnlyStore::class, $container->get(Store::class));
self::assertInstanceOf(StreamReadOnlyStore::class, $container->get(Store::class));
}

public function testMigrateStore(): void
Expand All @@ -344,15 +341,14 @@ public function testMigrateStore(): void
'translators' => [
'my_translator',
RecalculatePlayheadTranslator::class,
AggregateToStreamHeaderTranslator::class,
],
],
]
],
]
);

self::assertInstanceOf(DoctrineDbalStore::class, $container->get(Store::class));
self::assertInstanceOf(StreamDoctrineDbalStore::class, $container->get(Store::class));
self::assertInstanceOf(StreamDoctrineDbalStore::class, $container->get('event_sourcing.store.new_store'));
self::assertInstanceOf(StoreMigrateCommand::class, $container->get(StoreMigrateCommand::class));

Expand All @@ -364,9 +360,6 @@ public function testMigrateStore(): void
RecalculatePlayheadTranslator::class => [
['priority' => -1],
],
AggregateToStreamHeaderTranslator::class => [
['priority' => -2],
],
],
$container->findTaggedServiceIds('event_sourcing.translator')
);
Expand Down Expand Up @@ -1474,7 +1467,7 @@ public function testFullBuild(): void
);

self::assertInstanceOf(Connection::class, $container->get('event_sourcing.dbal_connection'));
self::assertInstanceOf(DoctrineDbalStore::class, $container->get(Store::class));
self::assertInstanceOf(StreamDoctrineDbalStore::class, $container->get(Store::class));
self::assertInstanceOf(DefaultEventBus::class, $container->get(EventBus::class));
self::assertInstanceOf(AggregateRootRegistry::class, $container->get(AggregateRootRegistry::class));
self::assertInstanceOf(RepositoryManager::class, $container->get(RepositoryManager::class));
Expand Down
Loading
Loading