diff --git a/Doctrine/Mapper/Factory/DocumentFactory.php b/Doctrine/Mapper/Factory/DocumentFactory.php index bcd0c9c4..9e737985 100644 --- a/Doctrine/Mapper/Factory/DocumentFactory.php +++ b/Doctrine/Mapper/Factory/DocumentFactory.php @@ -60,7 +60,7 @@ public function createDocument(MetaInformationInterface $metaInformation) $value = $field->getValue(); if ($value instanceof Collection) { - $document->addField($field->getNameWithAlias(), $this->mapCollection($field), $field->getBoost()); + $document->addField($field->getNameWithAlias(), $this->mapCollection($field, $metaInformation->getClassName()), $field->getBoost()); } elseif (is_object($value)) { $document->addField($field->getNameWithAlias(), $this->mapObject($field), $field->getBoost()); } else { @@ -90,7 +90,7 @@ private function mapObject(Field $field) $getterReturnValue = $this->callGetterMethod($value, $getter); if (is_object($getterReturnValue)) { - throw new SolrMappingException('The configured getter must return a string or array, got object'); + throw new SolrMappingException(sprintf('The configured getter "%s" in "%s" must return a string or array, got object', $getter, get_class($value))); } return $getterReturnValue; @@ -141,19 +141,20 @@ private function callGetterMethod($object, $getter) } /** - * @param Field $field + * @param Field $field + * @param string $sourceTargetClass * * @return array * * @throws SolrMappingException if no getter method was found */ - private function mapCollection(Field $field) + private function mapCollection(Field $field, $sourceTargetClass) { /** @var Collection $value */ $value = $field->getValue(); $getter = $field->getGetterName(); if ($getter == '') { - throw new SolrMappingException(sprintf('No getter method for property "%s" found', $field->name)); + throw new SolrMappingException(sprintf('No getter method for property "%s" configured in class "%s"', $field->name, $sourceTargetClass)); } $values = array(); diff --git a/Tests/Doctrine/Mapper/EntityMapperTest.php b/Tests/Doctrine/Mapper/EntityMapperTest.php index 94f900f0..9fa3beab 100644 --- a/Tests/Doctrine/Mapper/EntityMapperTest.php +++ b/Tests/Doctrine/Mapper/EntityMapperTest.php @@ -279,7 +279,7 @@ public function mapRelationFieldAllFields() /** * @test * @expectedException \FS\SolrBundle\Doctrine\Mapper\SolrMappingException - * @expectedExceptionMessage No getter method for property "collection" found + * @expectedExceptionMessage No getter method for property "collection" configured in class "FS\SolrBundle\Tests\Fixtures\ValidTestEntityWithCollection" */ public function throwExceptionIfEmbbededObjectsHasNoGetter() { @@ -414,7 +414,7 @@ public function callGetterWithParameters() /** * @test * @expectedException \FS\SolrBundle\Doctrine\Mapper\SolrMappingException - * @expectedExceptionMessage The configured getter must return a string or array, got object + * @expectedExceptionMessage The configured getter "asString" in "FS\SolrBundle\Tests\Doctrine\Mapper\TestObject" must return a string or array, got object */ public function callGetterWithObjectAsReturnValue() {