/** * @test */ public function classAnnotationTest() { $actual = $this->informer->getClassAnnotation('Flowpack\\ElasticSearch\\Tests\\Functional\\Fixtures\\JustFewPropertiesToIndex'); $this->assertInstanceOf('Flowpack\\ElasticSearch\\Annotations\\Indexable', $actual); $this->assertSame('dummyindex', $actual->indexName); $this->assertSame('sampletype', $actual->typeName); }
/** * Returns the ElasticSearch type for a specific object, by its annotation * * @param $object * @param \Flowpack\ElasticSearch\Domain\Model\Client $client * * @return \Flowpack\ElasticSearch\Domain\Model\GenericType */ protected function getIndexTypeForObject($object, Client $client = null) { if ($client === null) { $client = $this->client; } $className = $this->reflectionService->getClassNameByObject($object); $indexAnnotation = $this->indexInformer->getClassAnnotation($className); if ($indexAnnotation === null) { return null; } $index = $client->findIndex($indexAnnotation->indexName); $type = new GenericType($index, $indexAnnotation->typeName); return $type; }