[go: nahoru, domu]

Skip to content

Commit

Permalink
Configure the metadata cache for the extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
stof committed Jul 7, 2023
1 parent 28bda1e commit d20c9dd
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
],
"require": {
"php": "^7.2.5 || ^8.0",
"symfony/cache": "^5.4 || ^6.0",
"symfony/config": "^5.4 || ^6.0",
"symfony/dependency-injection": "^5.4 || ^6.0",
"symfony/event-dispatcher": "^5.4 || ^6.0",
"symfony/http-kernel": "^5.4 || ^6.0",
"gedmo/doctrine-extensions": "^2.3.12 || ^3.0.0"
"gedmo/doctrine-extensions": "^3.5.0"
},
"require-dev": {
"symfony/mime": "^5.4 || ^6.0",
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function getConfigTreeBuilder(): TreeBuilder
->booleanNode('translation_fallback')->defaultFalse()->end()
->booleanNode('persist_default_translation')->defaultFalse()->end()
->booleanNode('skip_translation_on_load')->defaultFalse()->end()
->scalarNode('metadata_cache_pool')->defaultNull()->end()
->end()
;

Expand Down
8 changes: 8 additions & 0 deletions src/DependencyInjection/StofDoctrineExtensionsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Stof\DoctrineExtensionsBundle\DependencyInjection;

use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
Expand Down Expand Up @@ -134,6 +136,12 @@ public function load(array $configs, ContainerBuilder $container)
}
}

if (isset($config['metadata_cache_pool'])) {
$container->setAlias('stof_doctrine_extensions.metadata_cache', new Alias($config['metadata_cache_pool'], false));
} else {
$container->register('stof_doctrine_extensions.metadata_cache', ArrayAdapter::class)->setPublic(false);
}

foreach ($config['class'] as $listener => $class) {
$container->setParameter(sprintf('stof_doctrine_extensions.listener.%s.class', $listener), $class);
}
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/blameable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
</parameters>
<services>
<service id="stof_doctrine_extensions.listener.blameable" class="%stof_doctrine_extensions.listener.blameable.class%" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/ip_traceable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

<services>
<service id="stof_doctrine_extensions.listener.ip_traceable" class="Gedmo\IpTraceable\IpTraceableListener" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/loggable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
</parameters>
<services>
<service id="stof_doctrine_extensions.listener.loggable" class="%stof_doctrine_extensions.listener.loggable.class%" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/reference_integrity.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</parameters>
<services>
<service id="stof_doctrine_extensions.listener.reference_integrity" class="%stof_doctrine_extensions.listener.reference_integrity.class%" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/sluggable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</parameters>
<services>
<service id="stof_doctrine_extensions.listener.sluggable" class="%stof_doctrine_extensions.listener.sluggable.class%" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/softdeleteable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</parameters>
<services>
<service id="stof_doctrine_extensions.listener.softdeleteable" class="%stof_doctrine_extensions.listener.softdeleteable.class%" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/sortable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</parameters>
<services>
<service id="stof_doctrine_extensions.listener.sortable" class="%stof_doctrine_extensions.listener.sortable.class%" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/timestampable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</parameters>
<services>
<service id="stof_doctrine_extensions.listener.timestampable" class="%stof_doctrine_extensions.listener.timestampable.class%" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/translatable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
</parameters>
<services>
<service id="stof_doctrine_extensions.listener.translatable" class="%stof_doctrine_extensions.listener.translatable.class%" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/tree.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
</parameters>
<services>
<service id="stof_doctrine_extensions.listener.tree" class="%stof_doctrine_extensions.listener.tree.class%" public="false">
<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down
3 changes: 3 additions & 0 deletions src/Resources/config/uploadable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<configurator service="stof_doctrine_extensions.uploadable.configurator" method="configure" />
<argument type="service" id="stof_doctrine_extensions.uploadable.mime_type_guesser" />

<call method="setCacheItemPool">
<argument type="service" id="stof_doctrine_extensions.metadata_cache" />
</call>
<call method="setAnnotationReader">
<argument type="service" id="annotation_reader" />
</call>
Expand Down

0 comments on commit d20c9dd

Please sign in to comment.