diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index ce1c982..44f7332 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -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; } diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index efaaa52..8f0e1b9 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -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' + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + )); + } }