/** * Returns a converter. * * @param string $index * @param string $type * @return Converter */ protected function getConverter($index, $type) { $metadata = $this->typesMetadataCollection->getTypeMetadata($type, $index); $converter = new Converter($metadata, $this->languageSeparator); return $converter; }
/** * Returns a mapping of live indices and types to the document classes in short notation that represent them * * @param string[] $documentClasses * @return IndicesAndTypesMetadataCollection */ private function getIndicesAndTypesMetadataCollection(array $documentClasses) { $allDocumentClassToIndexMappings = $this->documentMetadataCollection->getDocumentClassesIndices(); $documentClassToIndexMap = array_intersect_key($allDocumentClassToIndexMappings, array_flip($documentClasses)); $typesMetadataCollection = new IndicesAndTypesMetadataCollection(); $getLiveIndices = false; $classToTypeMap = $this->documentMetadataCollection->getClassToTypeMap($documentClasses); // If there are duplicate type names across the indices we're querying if (count($classToTypeMap) > count(array_unique($classToTypeMap))) { // We'll need to get the live index name for each type, so we can correctly map the results to the appropriate objects $getLiveIndices = true; } foreach ($documentClassToIndexMap as $documentClass => $indexManagerName) { // Build mappings of indices and types to metadata, for the Converter $liveIndex = $getLiveIndices ? $this->indexManagerFactory->get($indexManagerName)->getLiveIndex() : null; $documentMetadata = $this->documentMetadataCollection->getDocumentMetadata($documentClass); $typesMetadataCollection->setTypeMetadata($documentMetadata, $liveIndex); } return $typesMetadataCollection; }