Merge branch 'formapro-forks/fixing-bug-with-parent' into 3.0.x
This commit is contained in:
commit
b4c01f3641
|
@ -393,7 +393,13 @@ class FOSElasticaExtension extends Extension
|
||||||
$arguments[] = array(new Reference($callbackId), 'serialize');
|
$arguments[] = array(new Reference($callbackId), 'serialize');
|
||||||
} else {
|
} else {
|
||||||
$abstractId = 'fos_elastica.object_persister';
|
$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);
|
$serviceId = sprintf('fos_elastica.object_persister.%s.%s', $indexName, $typeName);
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace FOS\ElasticaBundle\Tests\Functional\DependencyInjection;
|
||||||
|
|
||||||
|
|
||||||
|
use FOS\ElasticaBundle\DependencyInjection\FOSElasticaExtension;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
|
class FOSElasticaExtensionTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function shouldAddParentParamToObjectPersisterCall()
|
||||||
|
{
|
||||||
|
|
||||||
|
$config = Yaml::parse(file_get_contents(__DIR__.'/config/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']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
Tests/Functional/DependencyInjection/config/config.yml
Normal file
21
Tests/Functional/DependencyInjection/config/config.yml
Normal 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" }
|
Loading…
Reference in a new issue