-2

I'm trying to make a source plugin for importing from mongodb. My plugin class is defined here:

class MongoDBSource extends SourcePluginBase implements ConfigurableInterface {

and inside the constructor I'm connecting to the mongo database:

$mongoClient = new MongoDB\Client($db_string);
$this->collection = $mongoClient->selectCollection($this->configuration['database'], $this->configuration['collection']);

I'm also initializing an iterator like this:

protected function initializeIterator()
{
  $this->iterator = $this->collection->listIndexes();
}

When I run drush migrate:status, I get this message:

[error] Could not retrieve source count from demo_article: Authentication failed.

I believe that listIndexes() shoots that error.

Any idea where it tries to authenticate? Isn't having an iterator class enough?

UPDATE: I should probably use find() instead of listIdexes(), but anyway it shoots the same error.

2
  • Where is it told what connection to use?
    – Kevin
    Oct 29 at 12:56
  • $db_string contains connection data. I'm connecting with it and I'm getting collection in the constructor and in initializeIterator I'm using that collection to get it's iterator object.
    – MilanG
    Oct 29 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.