Merge branch '3.0.x'

This commit is contained in:
Christophe Coevoet 2015-01-21 18:11:18 +01:00
commit 1cea135dc5
4 changed files with 62 additions and 2 deletions

View file

@ -12,8 +12,9 @@ https://github.com/FriendsOfSymfony/FOSElasticaBundle/compare/v3.0.0...v3.0.1
To generate a changelog summary since the last version, run
`git log --no-merges --oneline v3.0.0...3.0.x`
* 3.0.7 (Unreleased)
* 3.0.7 (2015-01-21)
* Fixed the indexing of parent/child relations, broken since 3.0 #774
* Fixed multi_field properties not being normalised #769
* 3.0.6 (2015-01-04)

View file

@ -396,7 +396,13 @@ class FOSElasticaExtension extends Extension
$arguments[] = array(new Reference($callbackId), 'serialize');
} else {
$abstractId = 'fos_elastica.object_persister';
$arguments[] = $this->indexConfigs[$indexName]['types'][$typeName]['mapping']['properties'];
$mapping = $this->indexConfigs[$indexName]['types'][$typeName]['mapping'];
$argument = $mapping['properties'];
if(isset($mapping['_parent'])){
$argument['_parent'] = $mapping['_parent'];
}
$arguments[] = $argument;
}
$serviceId = sprintf('fos_elastica.object_persister.%s.%s', $indexName, $typeName);

View file

@ -0,0 +1,32 @@
<?php
namespace FOS\ElasticaBundle\Tests\DependencyInjection;
use FOS\ElasticaBundle\DependencyInjection\FOSElasticaExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Yaml\Yaml;
class FOSElasticaExtensionTest extends \PHPUnit_Framework_TestCase
{
public function testShouldAddParentParamToObjectPersisterCall()
{
$config = Yaml::parse(file_get_contents(__DIR__.'/fixtures/config.yml'));
$containerBuilder = new ContainerBuilder;
$containerBuilder->setParameter('kernel.debug', true);
$extension = new FOSElasticaExtension;
$extension->load($config, $containerBuilder);
$this->assertTrue($containerBuilder->hasDefinition('fos_elastica.object_persister.test_index.child_field'));
$persisterCallDefinition = $containerBuilder->getDefinition('fos_elastica.object_persister.test_index.child_field');
$arguments = $persisterCallDefinition->getArguments();
$arguments = $arguments['index_3'];
$this->assertArrayHasKey('_parent', $arguments);
$this->assertEquals('parent_field', $arguments['_parent']['type']);
}
}

View file

@ -0,0 +1,21 @@
fos_elastica:
clients:
default:
url: http://localhost:9200
indexes:
test_index:
client: default
types:
parent_field:
mappings:
text: ~
persistence:
driver: orm
model: foo_model
child_field:
mappings:
text: ~
persistence:
driver: orm
model: foo_model
_parent: { type: "parent_field", property: "parent" }