public function FillPdfContextManager::loadEntities in FillPDF 8.4
Same name and namespace in other branches
- 5.0.x src/Service/FillPdfContextManager.php \Drupal\fillpdf\Service\FillPdfContextManager::loadEntities()
Loads the entities specified in $context['entity_ids'].
Parameters
array $context: The FillPDF request context as returned by FillPdfLinkManipulatorInterface::parseLink().
Return value
\Drupal\Core\Entity\EntityInterface[][] Multidimensional array of entities, keyed by ID and grouped by entity type. Returns an empty array if no matching entities are found.
Overrides FillPdfContextManagerInterface::loadEntities
See also
\Drupal\fillpdf\FillPdfLinkManipulatorInterface::parseLink()
File
- src/
Service/ FillPdfContextManager.php, line 30
Class
- FillPdfContextManager
- Helper class to load entities from a FillPDF context array.
Namespace
Drupal\fillpdf\ServiceCode
public function loadEntities(array $context) {
$entities = [];
foreach ($context['entity_ids'] as $entity_type => $entity_ids) {
$type_controller = $this->entityTypeManager
->getStorage($entity_type);
$entity_list = $type_controller
->loadMultiple($entity_ids);
if (!empty($entity_list)) {
// Initialize array.
$entities += [
$entity_type => [],
];
$entities[$entity_type] += $entity_list;
}
}
return $entities;
}