protected function EmbeddedImagesCollector::getAttachedFiles in Dependency Calculation 8
Builds list of attached files.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: Entity.
string $module: Module name.
Return value
\Drupal\file\Entity\File[] Files list.
1 call to EmbeddedImagesCollector::getAttachedFiles()
- EmbeddedImagesCollector::onCalculateDependencies in src/
EventSubscriber/ DependencyCollector/ EmbeddedImagesCollector.php - Reacts on CALCULATE_DEPENDENCIES event.
File
- src/
EventSubscriber/ DependencyCollector/ EmbeddedImagesCollector.php, line 92
Class
- EmbeddedImagesCollector
- Class EmbeddedImagesCollector.
Namespace
Drupal\depcalc\EventSubscriber\DependencyCollectorCode
protected function getAttachedFiles(EntityInterface $entity, string $module = 'file') : array {
$criteria = new Condition('AND');
$criteria
->condition('type', $entity
->getEntityTypeId())
->condition('count', '0', '>')
->condition('module', [
$module,
], 'in')
->condition('id', $entity
->id());
$rows = $this->database
->select('file_usage', 'f')
->fields('f', [
'fid',
])
->condition($criteria)
->execute()
->fetchAllAssoc('fid');
if (empty($rows)) {
return [];
}
$fids = array_keys($rows);
return File::loadMultiple($fids);
}