Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I created a custom entity type (similar to 'node'). The MongoDB fields storage and drush migration worked perfectly - all data is now in MongoDB. But loading through entity_load() still fails.
I tried this in my custom.module:
/**
* Needed to override Flatstore entity_load() to use MongoDB backend
*/
if (module_exists('mongodb_field_storage') && class_exists('CustomController')) {
class MongoDbCustomController extends CustomController {
function buildQuery($ids, $conditions = array(), $revision_id = FALSE) {
return new MongoDbEntityLoader($this->entityType, $ids, $conditions);
}
}
/**
* Implements hook_entity_info_alter().
*/
function custom_entity_info_alter(&$entity_info) {
$entity_info['custom']['controller class'] = 'MongoDb' . $info['controller class'];
}
}
I flushed caches etc. But then I get this error:
Call to undefined method MongoDB::load() in includes\common.inc on line 7623
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedGot one step closer. First problem was, my function custom_entity_info_alter() ran too late (before the actual entity info declaration). Now this works, but I get a new error:
Call to undefined method MongoDbEntityLoader::setFetchMode() in sites\all\modules\contrib\entity\includes\entity.controller.inc
Is this an entity.module issue, or not?
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedThe problem was in MongoDbEntityLoader::execute()
It does this:
I needed to change that to this:
It seems that there is function fetchAllAssoc() which could do that, but its not called in my case? Is that a bug?
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedWell this issue is fixed for me, I implemented a custom class to do my custom stuff.