diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index df0fe19..d44e714 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -325,7 +325,8 @@ class Configuration implements ConfigurationInterface ->scalarNode('type')->end() ->scalarNode('identifier')->defaultValue('id')->end() ->end() - ->end(); + ->end() + ->scalarNode('format')->end(); if (isset($nestings['fields'])) { $this->addNestedFieldConfig($node, $nestings, 'fields'); diff --git a/README.md b/README.md index c289cd6..1c5c5f3 100644 --- a/README.md +++ b/README.md @@ -666,3 +666,21 @@ fos_elastica: provider: finder: ``` + +#### Date format example + +If you want to specify a [date format](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html): + +```yaml +fos_elastica: + clients: + default: { host: localhost, port: 9200 } + indexes: + site: + types: + user: + mappings: + username: { type: string } + lastlogin: { type: date, format: basic_date_time } + birthday: { type: date, format: "yyyy-MM-dd" } +``` diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php new file mode 100644 index 0000000..f410621 --- /dev/null +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -0,0 +1,34 @@ +configuration = new Configuration(array()); + } + + public function testEmptyConfigContainsFormatMappingOptionNode() + { + $tree = $this->configuration->getConfigTree(); + $children = $tree->getChildren(); + $children = $children['indexes']->getPrototype()->getChildren(); + $typeNodes = $children['types']->getPrototype()->getChildren(); + $mappings = $typeNodes['mappings']->getPrototype()->getChildren(); + + $this->assertArrayHasKey('format', $mappings); + $this->assertInstanceOf('Symfony\Component\Config\Definition\ScalarNode', $mappings['format']); + $this->assertNull($mappings['format']->getDefaultValue()); + } +}