Unset fields if no nested fields are defined
This commit is contained in:
parent
514e63f26f
commit
455ff9e0f7
|
@ -334,6 +334,10 @@ class Configuration implements ConfigurationInterface
|
|||
$childrenNode = $node
|
||||
->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();
|
||||
|
|
|
@ -103,4 +103,34 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$this->assertEquals('http://www.github.com/', $configuration['clients']['default']['servers'][0]['url']);
|
||||
}
|
||||
|
||||
public function testEmptyFieldsIndexIsUnset()
|
||||
{
|
||||
$config = array(
|
||||
'indexes' => array(
|
||||
'test' => array(
|
||||
'types' => array(
|
||||
'test' => array(
|
||||
'mappings' => array(
|
||||
'title' => array(
|
||||
'type' => 'string',
|
||||
'fields' => array(
|
||||
'autocomplete' => null
|
||||
)
|
||||
),
|
||||
'content' => null
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$processor = new Processor();
|
||||
|
||||
$configuration = $processor->processConfiguration(new Configuration(array($config)), array($config));
|
||||
|
||||
$this->assertArrayNotHasKey('fields', $configuration['indexes']['test']['types']['test']['mappings']['content']);
|
||||
$this->assertArrayHasKey('fields', $configuration['indexes']['test']['types']['test']['mappings']['title']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue