From 5480e037e3a005edd548d44a7bc31fb66e406db9 Mon Sep 17 00:00:00 2001 From: Laszlo Horvath Date: Thu, 30 Jan 2014 12:39:48 +0100 Subject: [PATCH] adding ttl for documents --- DependencyInjection/Configuration.php | 21 ++++++++++++++++++++ DependencyInjection/FOSElasticaExtension.php | 3 +++ 2 files changed, 24 insertions(+) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index ca97a4d..4ed88af 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -299,6 +299,7 @@ class Configuration implements ConfigurationInterface ->append($this->getParentNode()) ->append($this->getAllNode()) ->append($this->getTimestampNode()) + ->append($this->getTtlNode()) ->end() ; @@ -669,4 +670,24 @@ class Configuration implements ConfigurationInterface return $node; } + + /** + * Returns the array node used for "_ttl" + */ + protected function getTtlNode() + { + $builder = new TreeBuilder(); + $node = $builder->root('_ttl'); + + $node + ->children() + ->scalarNode('enabled')->defaultValue(true)->end() + ->scalarNode('default')->end() + ->scalarNode('store')->end() + ->scalarNode('index')->end() + ->end() + ; + + return $node; + } } diff --git a/DependencyInjection/FOSElasticaExtension.php b/DependencyInjection/FOSElasticaExtension.php index a38b90a..52070fd 100644 --- a/DependencyInjection/FOSElasticaExtension.php +++ b/DependencyInjection/FOSElasticaExtension.php @@ -249,6 +249,9 @@ class FOSElasticaExtension extends Extension if (isset($type['_timestamp'])) { $this->indexConfigs[$indexName]['config']['mappings'][$name]['_timestamp'] = $type['_timestamp']; } + if (isset($type['_ttl'])) { + $this->indexConfigs[$indexName]['config']['mappings'][$name]['_ttl'] = $type['_ttl']; + } if (!empty($type['dynamic_templates'])) { $this->indexConfigs[$indexName]['config']['mappings'][$name]['dynamic_templates'] = array(); foreach ($type['dynamic_templates'] as $templateName => $templateData) {