Skip to content

Commit

Permalink
do not instantiate an ObjectPersister if model is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessandro Chitolina committed Jan 31, 2017
1 parent 9978cf8 commit 1869c0c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions DependencyInjection/FazlandElasticaExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,10 @@ private function loadObjectPersister(array $typeConfig, Reference $typeRef, Cont
return $typeConfig['persister']['service'];
}

if (!isset($typeConfig['model'])) {
return null;
}

$arguments = [
$typeRef,
new Reference($transformerId),
Expand Down Expand Up @@ -457,13 +461,11 @@ private function loadObjectPersister(array $typeConfig, Reference $typeRef, Cont
* @param string $objectPersisterId
* @param string $indexName
* @param string $typeName
*
* @return string
*/
private function loadTypeProvider(array $typeConfig, ContainerBuilder $container, $objectPersisterId, $indexName, $typeName)
{
if (isset($typeConfig['provider']['service'])) {
return $typeConfig['provider']['service'];
if (null === $objectPersisterId || isset($typeConfig['provider']['service'])) {
return;
}

/* Note: provider services may conflict with "prototype.driver", if the
Expand All @@ -480,8 +482,6 @@ private function loadTypeProvider(array $typeConfig, ContainerBuilder $container
'typeName' => $typeName,
]));
$container->setDefinition($providerId, $providerDef);

return $providerId;
}

/**
Expand All @@ -492,13 +492,11 @@ private function loadTypeProvider(array $typeConfig, ContainerBuilder $container
* @param string $objectPersisterId
* @param string $indexName
* @param string $typeName
*
* @return string
*/
private function loadTypeListener(array $typeConfig, ContainerBuilder $container, $objectPersisterId, $indexName, $typeName)
{
if (isset($typeConfig['listener']['service'])) {
return $typeConfig['listener']['service'];
if (null === $objectPersisterId || isset($typeConfig['listener']['service'])) {
return;
}

/* Note: listener services may conflict with "prototype.driver", if the
Expand Down Expand Up @@ -538,8 +536,6 @@ private function loadTypeListener(array $typeConfig, ContainerBuilder $container
}

$container->setDefinition($listenerId, $listenerDef);

return $listenerId;
}

/**
Expand Down

0 comments on commit 1869c0c

Please sign in to comment.