From 4baefe6686206fb3babeb483e4fe44fd799d9e21 Mon Sep 17 00:00:00 2001 From: Richard Miller Date: Wed, 15 Feb 2012 10:27:03 +0000 Subject: [PATCH] Fixed normalizing values twice in transfomer --- Transformer/ModelToElasticaAutoTransformer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Transformer/ModelToElasticaAutoTransformer.php b/Transformer/ModelToElasticaAutoTransformer.php index 6a8a381..910d1cf 100644 --- a/Transformer/ModelToElasticaAutoTransformer.php +++ b/Transformer/ModelToElasticaAutoTransformer.php @@ -49,8 +49,8 @@ class ModelToElasticaAutoTransformer implements ModelToElasticaTransformerInterf if (!method_exists($class, $getter)) { throw new RuntimeException(sprintf('The getter %s::%s does not exist', $class, $getter)); } - if ($value = $this->normalizeValue($object->$getter()) !== null) { - $array[$key] = $this->normalizeValue($object->$getter()); + if (null !== $value = $this->normalizeValue($object->$getter())) { + $array[$key] = $value; } } $identifierGetter = 'get'.ucfirst($this->options['identifier']); @@ -71,7 +71,7 @@ class ModelToElasticaAutoTransformer implements ModelToElasticaTransformerInterf $normalizeValue = function(&$v) { if ($v instanceof \DateTime) { $v = (int) $v->format('U'); - } elseif (!is_int($v) && !is_float($v) && !is_bool($v) && !is_null($v)) { + } elseif (!is_scalar($v) && !is_null($v)) { $v = (string) $v; } };