public function MongodbFileUsage::listUsage in MongoDB 8
Determines where a file is used.
Parameters
\Drupal\file\FileInterface $file: A file entity.
Return value
array A nested array with usage data. The first level is keyed by module name, the second by object type and the third by the object id. The value of the third level contains the usage count.
Overrides FileUsageInterface::listUsage
File
- src/
MongodbFileUsage.php, line 98 - Definition of Drupal\mongodb\MongodbFileUsage.
Class
- MongodbFileUsage
- Defines the mongodb file usage backend.
Namespace
Drupal\mongodbCode
public function listUsage(FileInterface $file) {
$key = array(
'fid' => (int) $file
->id(),
'count' => array(
'$gt' => 0,
),
);
$results = $this->database
->get($this->collection)
->find($key);
$references = array();
foreach ($results as $usage) {
$references[$usage['module']][$usage['type']][$usage['id']] = $usage['count'];
}
return $references;
}