Unset nested "fields" for deeper nested configs too
This commit is contained in:
parent
40e79b2abe
commit
588c4e2d02
|
@ -458,6 +458,10 @@ class Configuration implements ConfigurationInterface
|
||||||
->arrayNode($property)
|
->arrayNode($property)
|
||||||
->useAttributeAsKey('name')
|
->useAttributeAsKey('name')
|
||||||
->prototype('array')
|
->prototype('array')
|
||||||
|
->validate()
|
||||||
|
->ifTrue(function($v) { return isset($v['fields']) && empty($v['fields']); })
|
||||||
|
->then(function($v) { unset($v['fields']); return $v; })
|
||||||
|
->end()
|
||||||
->treatNullLike(array())
|
->treatNullLike(array())
|
||||||
->addDefaultsIfNotSet()
|
->addDefaultsIfNotSet()
|
||||||
->children();
|
->children();
|
||||||
|
|
|
@ -118,7 +118,19 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||||
'autocomplete' => null
|
'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->assertArrayNotHasKey('fields', $configuration['indexes']['test']['types']['test']['mappings']['content']);
|
||||||
$this->assertArrayHasKey('fields', $configuration['indexes']['test']['types']['test']['mappings']['title']);
|
$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']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue