class MongoDbEntityLoader in MongoDB 7
Hierarchy
- class \MongoDbEntityLoader
Expanded class hierarchy of MongoDbEntityLoader
File
- mongodb_field_storage/
mongodb_field_storage.module, line 583 - Implementation of the field storage API for MongoDB.
View source
class MongoDbEntityLoader {
/**
* Query results.
*
* @var array
*/
protected $result;
/**
* MongoDbEntityLoader constructor.
*
* @param string $entityType
* The type of entity to load.
* @param array $ids
* The IDs of the entities to load.
* @param array $conditions
* The conditions under which to load the entities.
*/
public function __construct($entityType, array $ids, array $conditions) {
$this->entityType = $entityType;
$this->ids = $ids;
$this->conditions = $conditions;
}
/**
* Perform the load.
*
* @return $this
*
* @throws \MongoConnectionException
*/
public function execute() {
$entities = array();
if ($this->ids) {
$this->conditions['_id']['$in'] = array_map('intval', $this->ids);
foreach ($this->ids as $id) {
$entities[$id] = FALSE;
}
}
foreach (mongodb_collection('fields_current', $this->entityType)
->find($this->conditions) as $result) {
$entities[$result['_id']] = (object) $result;
}
$this->result = array_filter($entities);
return $this;
}
/**
* Fetch the query results.
*
* @return array
* The result documents.
*/
public function fetchAllAssoc() {
return $this->result;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MongoDbEntityLoader:: |
protected | property | Query results. | |
MongoDbEntityLoader:: |
public | function | Perform the load. | |
MongoDbEntityLoader:: |
public | function | Fetch the query results. | |
MongoDbEntityLoader:: |
public | function | MongoDbEntityLoader constructor. |