MongodbVocabularyStorage.php in MongoDB 8
File
mongodb_taxonomy/src/MongodbVocabularyStorage.php
View source
<?php
namespace Drupal\mongodb_taxonomy;
use Drupal\Core\Config\Entity\ConfigEntityStorage;
use Drupal\taxonomy\VocabularyStorageInterface;
class MongodbVocabularyStorage extends ConfigEntityStorage implements VocabularyStorageInterface {
public function getToplevelTids($vids) {
$return = [];
$collection = \Drupal::service('mongo')
->get('entity.taxonomy_term');
foreach ($collection
->find([
'bundle' => [
'$in' => $vids,
],
], [
'_id' => TRUE,
]) as $row) {
$return[] = $row['_id'];
}
return $return;
}
}