/** * @param string $className * @param \Flowpack\ElasticSearch\Annotations\Indexable $annotation * @return Mapping */ protected function buildMappingFromClassAndAnnotation($className, \Flowpack\ElasticSearch\Annotations\Indexable $annotation) { $index = new \Flowpack\ElasticSearch\Domain\Model\Index($annotation->indexName); $type = new \Flowpack\ElasticSearch\Domain\Model\GenericType($index, $annotation->typeName); $mapping = new Mapping($type); foreach ($this->indexInformer->getClassProperties($className) as $propertyName) { $this->augmentMappingByProperty($mapping, $className, $propertyName); } return $mapping; }
/** * 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; }
/** * @test */ public function classWithNoPropertyAnnotatedHasAllPropertiesToBeIndexed() { $actual = $this->informer->getClassProperties('Flowpack\\ElasticSearch\\Tests\\Functional\\Fixtures\\Tweet'); $this->assertGreaterThan(1, $actual); }