From ebb5344aaacbc74d7410e911e21bfb5ccf289324 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Tue, 16 Jun 2026 16:39:28 +0200 Subject: [PATCH 1/4] Configure a shared cache for storing resolved annotations and attribute values --- composer.json | 6 ++++++ src/DependencyInjection/Configuration.php | 6 +++++- .../HostnetEntityTrackerExtension.php | 15 +++++++++++++-- src/Resources/config/blamable.yaml | 1 + src/Resources/config/mutation.yaml | 1 + src/Resources/config/revision.yaml | 1 + src/Resources/config/services.yaml | 4 ++++ tests/DependencyInjection/ConfigurationTest.php | 3 ++- 8 files changed, 33 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 7fcec4c..0395cdc 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,12 @@ "hostnet/entity-mutation-component": "Provides the @Mutation annotation and listeners", "hostnet/entity-revision-component": "Provides the @Revision annotation and listeners" }, + "conflict": { + "hostnet/entity-blamable-component": "<=1.0.7", + "hostnet/entity-mutation-component": "<=1.0.7", + "hostnet/entity-revision-component": "<=1.1.8", + "hostnet/entity-tracker-component": "<=2.2.3" + }, "autoload": { "psr-4": { "Hostnet\\Bundle\\EntityTrackerBundle\\": "src/" diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 4527646..da1424d 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -57,7 +57,11 @@ public function getConfigTreeBuilder(): TreeBuilder ->arrayNode('mutation') ->info(sprintf($component_info, 'mutation')) ->end() - ->end(); + ->scalarNode('cache') + ->info('Specifies cacheadapter service to use') + ->cannotBeEmpty() + ->defaultValue('entity_tracker.cache') + ->end(); return $tree_builder; } diff --git a/src/DependencyInjection/HostnetEntityTrackerExtension.php b/src/DependencyInjection/HostnetEntityTrackerExtension.php index 01c416c..e42b3df 100644 --- a/src/DependencyInjection/HostnetEntityTrackerExtension.php +++ b/src/DependencyInjection/HostnetEntityTrackerExtension.php @@ -26,6 +26,11 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('services.yaml'); + $cache = $config['cache']; + $container + ->getDefinition('entity_tracker.listener.entity_changed') + ->replaceArgument(3, new Reference($cache)); + if (\array_key_exists('blamable', $config)) { $this->validateComponent(self::BLAMABLE, 'blamable'); $loader->load('blamable.yaml'); @@ -37,7 +42,8 @@ public function load(array $configs, ContainerBuilder $container): void $container ->getDefinition('entity_tracker.listener.blamable') - ->replaceArgument(1, new Reference($config['blamable']['provider'])); + ->replaceArgument(1, new Reference($config['blamable']['provider'])) + ->replaceArgument(2, new Reference($cache)); if (isset($config['blamable']['default_username'])) { $container @@ -53,7 +59,8 @@ public function load(array $configs, ContainerBuilder $container): void $loader->load('revision.yaml'); $container ->getDefinition('entity_tracker.listener.revision') - ->replaceArgument(1, new Reference($config['revision']['factory'])); + ->replaceArgument(1, new Reference($config['revision']['factory'])) + ->replaceArgument(3, new Reference($cache)); } else { $this->validateClass(self::REVISION, 'revision'); } @@ -61,6 +68,10 @@ public function load(array $configs, ContainerBuilder $container): void if (\array_key_exists('mutation', $config)) { $this->validateComponent(self::MUTATION, 'mutation'); $loader->load('mutation.yaml'); + + $container + ->getDefinition('entity_tracker.listener.mutation') + ->replaceArgument(1, new Reference($cache)); } else { $this->validateClass(self::MUTATION, 'mutation'); } diff --git a/src/Resources/config/blamable.yaml b/src/Resources/config/blamable.yaml index 1704df0..a8a0386 100644 --- a/src/Resources/config/blamable.yaml +++ b/src/Resources/config/blamable.yaml @@ -9,6 +9,7 @@ services: arguments: - "@entity_tracker.resolver.blamable" - "" # provider id, (configurable) + - "" tags: - { name: doctrine.event_listener, event: entityChanged, priority: 32, method: onEntityChanged } diff --git a/src/Resources/config/mutation.yaml b/src/Resources/config/mutation.yaml index fa77b3f..eaa68dc 100644 --- a/src/Resources/config/mutation.yaml +++ b/src/Resources/config/mutation.yaml @@ -8,5 +8,6 @@ services: class: Hostnet\Component\EntityMutation\Listener\MutationListener arguments: - "@entity_tracker.resolver.mutation" + - "" tags: - { name: doctrine.event_listener, event: entityChanged, priority: 8 } diff --git a/src/Resources/config/revision.yaml b/src/Resources/config/revision.yaml index a6d81e9..18ae1bb 100644 --- a/src/Resources/config/revision.yaml +++ b/src/Resources/config/revision.yaml @@ -10,6 +10,7 @@ services: - "@entity_tracker.resolver.revision" - "" # factory service id, (configurable) - "@logger" + - "" tags: - { name: doctrine.event_listener, event: entityChanged, priority: 16 } - { name: doctrine.event_listener, event: postFlush, priority: 20 } diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index d7aae15..526bbaf 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -1,4 +1,7 @@ services: + entity_tracker.cache: + class: Symfony\Component\Cache\Adapter\ArrayAdapter + entity_tracker.provider.annotation_metadata: class: Hostnet\Component\EntityTracker\Provider\EntityAnnotationMetadataProvider arguments: @@ -16,6 +19,7 @@ services: - "@entity_tracker.provider.annotation_metadata" - "@entity_tracker.provider.mutation_metadata" - "@?logger" + - "" tags: - { name: doctrine.event_listener, event: preFlush, priority: 15 } - { name: doctrine.event_listener, event: prePersist, priority: 15 } diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 0f76374..6209aab 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -21,6 +21,7 @@ public function testValid(): void 'blamable' => ['provider' => 'henk', 'default_username' => 'eux'], 'revision' => ['factory' => 'henk'], 'mutation' => [], + 'cache' => 'entity_tracker.cache', ], ]; @@ -39,7 +40,7 @@ public function testEmptyConfig(array $configs): void $processor = new Processor(); $configuration = new Configuration(); - self::assertEmpty($processor->processConfiguration($configuration, $configs)); + self::assertSame(['cache' => 'entity_tracker.cache'], $processor->processConfiguration($configuration, $configs)); } public function emptyConfigProvider(): array From d9e6d884c5a00afdb445ac2cbf29ffb3f7ab33d4 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Thu, 18 Jun 2026 13:15:54 +0200 Subject: [PATCH 2/4] Update dependencies --- composer.json | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 0395cdc..d0b40e7 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "minimum-stability": "stable", "require": { "php": "^8.3", - "hostnet/entity-tracker-component": "^2.0.0", + "hostnet/entity-tracker-component": "^2.3.0", "psr/log": "^1.1.0||^2.0.0||^3.0.0", "symfony/config": "^5.4||^6.0", "symfony/dependency-injection": "^5.4||^6.0", @@ -13,7 +13,7 @@ "symfony/yaml": "^5.4||^6.0" }, "require-dev": { - "hostnet/entity-blamable-component": "^1.0.4", + "hostnet/entity-blamable-component": "^1.1.0", "hostnet/phpcs-tool": "^9.1.0", "phpspec/prophecy": "^1.19", "phpspec/prophecy-phpunit": "^2.2", @@ -22,15 +22,14 @@ "symfony/security-bundle": "^5.4||^6.0" }, "suggest": { - "hostnet/entity-blamable-component": "Provides the @Blamable annotation and listeners", - "hostnet/entity-mutation-component": "Provides the @Mutation annotation and listeners", - "hostnet/entity-revision-component": "Provides the @Revision annotation and listeners" + "hostnet/entity-blamable-component": "Provides the @Blamable annotation/attribute and listeners", + "hostnet/entity-mutation-component": "Provides the @Mutation annotation/attribute and listeners", + "hostnet/entity-revision-component": "Provides the @Revision annotation/attribute and listeners" }, "conflict": { - "hostnet/entity-blamable-component": "<=1.0.7", - "hostnet/entity-mutation-component": "<=1.0.7", - "hostnet/entity-revision-component": "<=1.1.8", - "hostnet/entity-tracker-component": "<=2.2.3" + "hostnet/entity-blamable-component": "<1.1.0", + "hostnet/entity-mutation-component": "<1.1.0", + "hostnet/entity-revision-component": "<1.2.0" }, "autoload": { "psr-4": { From b4ff8897afd38413c790232a3ce1773371868532 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Thu, 18 Jun 2026 13:17:08 +0200 Subject: [PATCH 3/4] phpcs --- tests/DependencyInjection/ConfigurationTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index 6209aab..14904ce 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -40,7 +40,10 @@ public function testEmptyConfig(array $configs): void $processor = new Processor(); $configuration = new Configuration(); - self::assertSame(['cache' => 'entity_tracker.cache'], $processor->processConfiguration($configuration, $configs)); + self::assertSame( + ['cache' => 'entity_tracker.cache'], + $processor->processConfiguration($configuration, $configs) + ); } public function emptyConfigProvider(): array From 8d37d5f8bbe74f0c2eaf0f1e5df9c55d6a23c324 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Fri, 19 Jun 2026 08:05:01 +0200 Subject: [PATCH 4/4] Add comments to configurable services --- src/Resources/config/blamable.yaml | 2 +- src/Resources/config/mutation.yaml | 2 +- src/Resources/config/revision.yaml | 2 +- src/Resources/config/services.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Resources/config/blamable.yaml b/src/Resources/config/blamable.yaml index a8a0386..aa7a494 100644 --- a/src/Resources/config/blamable.yaml +++ b/src/Resources/config/blamable.yaml @@ -9,7 +9,7 @@ services: arguments: - "@entity_tracker.resolver.blamable" - "" # provider id, (configurable) - - "" + - "" # cacheadapter id (configurable, entity_tracker.cache by default) tags: - { name: doctrine.event_listener, event: entityChanged, priority: 32, method: onEntityChanged } diff --git a/src/Resources/config/mutation.yaml b/src/Resources/config/mutation.yaml index eaa68dc..cbe462f 100644 --- a/src/Resources/config/mutation.yaml +++ b/src/Resources/config/mutation.yaml @@ -8,6 +8,6 @@ services: class: Hostnet\Component\EntityMutation\Listener\MutationListener arguments: - "@entity_tracker.resolver.mutation" - - "" + - "" # cacheadapter id (configurable, entity_tracker.cache by default) tags: - { name: doctrine.event_listener, event: entityChanged, priority: 8 } diff --git a/src/Resources/config/revision.yaml b/src/Resources/config/revision.yaml index 18ae1bb..ec3dfa9 100644 --- a/src/Resources/config/revision.yaml +++ b/src/Resources/config/revision.yaml @@ -10,7 +10,7 @@ services: - "@entity_tracker.resolver.revision" - "" # factory service id, (configurable) - "@logger" - - "" + - "" # cacheadapter id (configurable, entity_tracker.cache by default) tags: - { name: doctrine.event_listener, event: entityChanged, priority: 16 } - { name: doctrine.event_listener, event: postFlush, priority: 20 } diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index 526bbaf..2ca9432 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -19,7 +19,7 @@ services: - "@entity_tracker.provider.annotation_metadata" - "@entity_tracker.provider.mutation_metadata" - "@?logger" - - "" + - "" # cacheadapter id (configurable, entity_tracker.cache by default) tags: - { name: doctrine.event_listener, event: preFlush, priority: 15 } - { name: doctrine.event_listener, event: prePersist, priority: 15 }