/**
  * @param Mapping $mapping
  * @param string $className
  * @param string $propertyName
  *
  * @throws \Flowpack\ElasticSearch\Exception
  * @return void
  */
 protected function augmentMappingByProperty(Mapping $mapping, $className, $propertyName)
 {
     list($propertyType) = $this->reflectionService->getPropertyTagValues($className, $propertyName, 'var');
     if (($transformAnnotation = $this->reflectionService->getPropertyAnnotation($className, $propertyName, 'Flowpack\\ElasticSearch\\Annotations\\Transform')) !== NULL) {
         $mappingType = $this->transformerFactory->create($transformAnnotation->type)->getTargetMappingType();
     } elseif (\TYPO3\Flow\Utility\TypeHandling::isSimpleType($propertyType)) {
         $mappingType = $propertyType;
     } elseif ($propertyType === '\\DateTime') {
         $mappingType = 'date';
     } else {
         throw new \Flowpack\ElasticSearch\Exception('Mapping is only supported for simple types and DateTime objects; "' . $propertyType . '" given but without a Transform directive.');
     }
     $mapping->setPropertyByPath($propertyName, array('type' => $mappingType));
     $annotation = $this->reflectionService->getPropertyAnnotation($className, $propertyName, 'Flowpack\\ElasticSearch\\Annotations\\Mapping');
     if ($annotation instanceof MappingAnnotation) {
         $mapping->setPropertyByPath($propertyName, $this->processMappingAnnotation($annotation, $mapping->getPropertyByPath($propertyName)));
         if ($annotation->getFields()) {
             foreach ($annotation->getFields() as $multiFieldAnnotation) {
                 $multiFieldIndexName = trim($multiFieldAnnotation->index_name);
                 if ($multiFieldIndexName === '') {
                     throw new \Flowpack\ElasticSearch\Exception('Multi field require an unique index name "' . $className . '::' . $propertyName . '".');
                 }
                 if (isset($multiFields[$multiFieldIndexName])) {
                     throw new \Flowpack\ElasticSearch\Exception('Duplicate index name in the same multi field is not allowed "' . $className . '::' . $propertyName . '".');
                 }
                 $multiFieldAnnotation->type = $mappingType;
                 $multiFields[$multiFieldIndexName] = $this->processMappingAnnotation($multiFieldAnnotation);
             }
             $mapping->setPropertyByPath(array($propertyName, 'fields'), $multiFields);
         }
     }
 }
 /**
  * Returns a multidimensional array with the indexable, probably transformed values of an object
  *
  * @param $object
  *
  * @return array
  */
 protected function getIndexablePropertiesAndValuesFromObject($object)
 {
     $className = $this->reflectionService->getClassNameByObject($object);
     $data = array();
     foreach ($this->indexInformer->getClassProperties($className) as $propertyName) {
         $value = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($object, $propertyName);
         if (($transformAnnotation = $this->reflectionService->getPropertyAnnotation($className, $propertyName, 'Flowpack\\ElasticSearch\\Annotations\\Transform')) !== null) {
             $value = $this->transformerFactory->create($transformAnnotation->type)->transformByAnnotation($value, $transformAnnotation);
         }
         $data[$propertyName] = $value;
     }
     return $data;
 }