Add date format field
This commit is contained in:
parent
4a889406e9
commit
9d1201099d
|
@ -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');
|
||||
|
|
18
README.md
18
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" }
|
||||
```
|
||||
|
|
34
Tests/DependencyInjection/ConfigurationTest.php
Normal file
34
Tests/DependencyInjection/ConfigurationTest.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace FOS\ElasticaBundle\Tests\Resetter\DependencyInjection;
|
||||
|
||||
use FOS\ElasticaBundle\DependencyInjection\Configuration;
|
||||
|
||||
/**
|
||||
* ConfigurationTest
|
||||
*/
|
||||
class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var Configuration
|
||||
*/
|
||||
private $configuration;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->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());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue