You are here

public function MongodbVocabularyStorage::getToplevelTids in MongoDB 8

@todo: this is a cheat and returns every term. To be fixed when hiearchy is added.

Overrides VocabularyStorageInterface::getToplevelTids

File

mongodb_taxonomy/src/MongodbVocabularyStorage.php, line 23
Contains \Drupal\mongodb_taxonomy\MongodbVocabularyStorage.

Class

MongodbVocabularyStorage

Namespace

Drupal\mongodb_taxonomy

Code

public function getToplevelTids($vids) {

  /** @var \MongoCollection $collection */
  $return = [];
  $collection = \Drupal::service('mongo')
    ->get('entity.taxonomy_term');
  foreach ($collection
    ->find([
    'bundle' => [
      '$in' => $vids,
    ],
  ], [
    '_id' => TRUE,
  ]) as $row) {
    $return[] = $row['_id'];
  }
  return $return;
}