public static function EntityBrowserBlock::loadEntitiesByIDs in Entity Browser Block 8
Loads entities based on an ID in the format entity_type:entity_id.
Parameters
array $ids: An array of IDs.
Return value
\Drupal\Core\Entity\EntityInterface[] An array of loaded entities, keyed by an ID.
3 calls to EntityBrowserBlock::loadEntitiesByIDs()
- EntityBrowserBlock::blockForm in src/
Plugin/ Block/ EntityBrowserBlock.php - Overrides \Drupal\Core\Block\BlockBase::blockForm().
- EntityBrowserBlock::build in src/
Plugin/ Block/ EntityBrowserBlock.php - Builds and returns the renderable array for this block plugin.
- EntityBrowserBlock::processTable in src/
Plugin/ Block/ EntityBrowserBlock.php - Render API callback: Processes the table element.
File
- src/
Plugin/ Block/ EntityBrowserBlock.php, line 213
Class
- EntityBrowserBlock
- Defines a generic entity browser block type.
Namespace
Drupal\entity_browser_block\Plugin\BlockCode
public static function loadEntitiesByIDs($ids) {
$storages = [];
$entities = [];
foreach ($ids as $id) {
list($entity_type_id, $entity_id) = explode(':', $id);
if (!isset($storages[$entity_type_id])) {
$storages[$entity_type_id] = \Drupal::entityTypeManager()
->getStorage($entity_type_id);
}
$entities[$entity_type_id . ':' . $entity_id] = $storages[$entity_type_id]
->load($entity_id);
}
return $entities;
}