Exemplo n.º 1
0
 /**
  * Return the metadata for documents for this index,
  * optionally filtered by specific document classes in short notation (e.g. AppBundle:Product)
  *
  * @param array $documentClasses If given, only metadata for those classes will be returned
  * @return DocumentMetadata[]
  */
 public function getDocumentsMetadata(array $documentClasses = [])
 {
     $metadata = $this->metadataCollection->getDocumentsMetadataForIndex($this->managerName);
     if (!empty($documentClasses)) {
         return array_intersect_key($metadata, array_flip($documentClasses));
     }
     return $metadata;
 }
Exemplo n.º 2
0
 /**
  * Verify that all types are in indices using the same connection object and return that object
  *
  * @param array $documentClasses
  * @return ConnectionManager
  */
 private function getConnection(array $documentClasses)
 {
     $connection = null;
     foreach ($documentClasses as $documentClass) {
         $indexManagerName = $this->documentMetadataCollection->getDocumentClassIndex($documentClass);
         $indexManager = $this->indexManagerFactory->get($indexManagerName);
         if (!is_null($connection) && $indexManager->getConnection()->getConnectionName() != $connection->getConnectionName()) {
             throw new \InvalidArgumentException(sprintf('All searched types must be in indices within the same connection'));
         }
         $connection = $indexManager->getConnection();
     }
     return $connection;
 }
 /**
  * @return DocumentMetadata The metadata for the ES type the provider is for
  */
 protected function getDocumentMetadata()
 {
     return $this->metadataCollection->getDocumentMetadata($this->documentClass);
 }