Ignore missing index hits
This commit is contained in:
parent
a161b0657a
commit
00b67fd8a4
|
@ -170,6 +170,7 @@ class Configuration implements ConfigurationInterface
|
|||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('hydrate')->defaultTrue()->end()
|
||||
->scalarNode('ignore_missing')->defaultFalse()->end()
|
||||
->scalarNode('service')->end()
|
||||
->end()
|
||||
->end()
|
||||
|
@ -250,6 +251,7 @@ class Configuration implements ConfigurationInterface
|
|||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('hydrate')->defaultTrue()->end()
|
||||
->scalarNode('ignore_missing')->defaultFalse()->end()
|
||||
->scalarNode('service')->end()
|
||||
->end()
|
||||
->end()
|
||||
|
|
|
@ -272,8 +272,9 @@ class FOSElasticaExtension extends Extension
|
|||
|
||||
$serviceDef->replaceArgument($argPos, $typeConfig['model']);
|
||||
$serviceDef->replaceArgument($argPos + 1, array(
|
||||
'identifier' => $typeConfig['identifier'],
|
||||
'hydrate' => $typeConfig['elastica_to_model_transformer']['hydrate']
|
||||
'hydrate' => $typeConfig['elastica_to_model_transformer']['hydrate'],
|
||||
'identifier' => $typeConfig['identifier'],
|
||||
'ignore_missing' => $typeConfig['elastica_to_model_transformer']['ignore_missing']
|
||||
));
|
||||
$container->setDefinition($serviceId, $serviceDef);
|
||||
|
||||
|
|
|
@ -32,8 +32,9 @@ abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTran
|
|||
* @var array
|
||||
*/
|
||||
protected $options = array(
|
||||
'hydrate' => true,
|
||||
'identifier' => 'id'
|
||||
'hydrate' => true,
|
||||
'identifier' => 'id',
|
||||
'ignore_missing' => false,
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -94,7 +95,7 @@ abstract class AbstractElasticaToModelTransformer implements ElasticaToModelTran
|
|||
}
|
||||
|
||||
$objects = $this->findByIdentifiers($ids, $this->options['hydrate']);
|
||||
if (count($objects) < count($elasticaObjects)) {
|
||||
if (!$this->options['ignore_missing'] && count($objects) < count($elasticaObjects)) {
|
||||
throw new \RuntimeException('Cannot find corresponding Doctrine objects for all Elastica results.');
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue