Merge pull request #593 from merk/gh-592

Fix nested property configuration
This commit is contained in:
Tim Nagel 2014-06-17 09:48:22 +10:00
commit 02d864f7e2
2 changed files with 53 additions and 5 deletions

View file

@ -20,7 +20,6 @@ class Configuration implements ConfigurationInterface
public function __construct($configArray, $debug)
{
$this->configArray = $configArray;
$this->debug = $debug;
}
@ -388,13 +387,16 @@ class Configuration implements ConfigurationInterface
}
foreach ($index['types'] as $type) {
if (empty($type['mappings'])) {
continue;
if (array_key_exists('mappings', $type) and !empty($type['mappings'])) {
$nestings = array_merge_recursive($nestings, $this->getNestingsForType($type['mappings'], $nestings));
}
$nestings = array_merge_recursive($nestings, $this->getNestingsForType($type['mappings'], $nestings));
if (array_key_exists('properties', $type) and !empty($type['properties'])) {
$nestings = array_merge_recursive($nestings, $this->getNestingsForType($type['properties'], $nestings));
}
}
}
return $nestings;
}

View file

@ -22,7 +22,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
private function getConfigs(array $configArray)
{
$configuration = new Configuration($configArray, true);
$configuration = new Configuration(array($configArray), true);
return $this->processor->processConfiguration($configuration, array($configArray));
}
@ -257,4 +257,50 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
$this->assertCount(3, $configuration['indexes']['test']['types']['test']['properties']);
}
public function testNestedProperties()
{
$configuration = $this->getConfigs(array(
'clients' => array(
'default' => array('url' => 'http://localhost:9200'),
),
'indexes' => array(
'test' => array(
'types' => array(
'user' => array(
'properties' => array(
'field1' => array(),
),
'persistence' => array(),
),
'user_profile' => array(
'_parent' => array(
'type' => 'user',
'property' => 'owner',
),
'properties' => array(
'field1' => array(),
'field2' => array(
'type' => 'nested',
'properties' => array(
'nested_field1' => array(
'type' => 'integer'
),
'nested_field2' => array(
'type' => 'object',
'properties' => array(
'id' => array(
'type' => 'integer'
)
)
)
)
)
)
)
)
)
)
));
}
}