Merge pull request #525 from jvandesande/MultiField

Unset nested "fields" for deeper nested configs too
This commit is contained in:
Tim Nagel 2014-04-01 09:11:31 +11:00
commit 5855ac6fbd
2 changed files with 19 additions and 1 deletions

View file

@ -458,6 +458,10 @@ class Configuration implements ConfigurationInterface
->arrayNode($property)
->useAttributeAsKey('name')
->prototype('array')
->validate()
->ifTrue(function($v) { return isset($v['fields']) && empty($v['fields']); })
->then(function($v) { unset($v['fields']); return $v; })
->end()
->treatNullLike(array())
->addDefaultsIfNotSet()
->children();

View file

@ -118,7 +118,19 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
'autocomplete' => null
)
),
'content' => null
'content' => null,
'children' => array(
'type' => 'nested',
'properties' => array(
'title' => array(
'type' => 'string',
'fields' => array(
'autocomplete' => null
)
),
'content' => null
)
)
)
)
)
@ -132,5 +144,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
$this->assertArrayNotHasKey('fields', $configuration['indexes']['test']['types']['test']['mappings']['content']);
$this->assertArrayHasKey('fields', $configuration['indexes']['test']['types']['test']['mappings']['title']);
$this->assertArrayNotHasKey('fields', $configuration['indexes']['test']['types']['test']['mappings']['children']['properties']['content']);
$this->assertArrayHasKey('fields', $configuration['indexes']['test']['types']['test']['mappings']['children']['properties']['title']);
}
}