class FillPdfContextManager in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 src/Service/FillPdfContextManager.php \Drupal\fillpdf\Service\FillPdfContextManager
Helper class to load entities from a FillPDF context array.
Hierarchy
- class \Drupal\fillpdf\Service\FillPdfContextManager implements FillPdfContextManagerInterface
Expanded class hierarchy of FillPdfContextManager
1 string reference to 'FillPdfContextManager'
1 service uses FillPdfContextManager
File
- src/
Service/ FillPdfContextManager.php, line 11
Namespace
Drupal\fillpdf\ServiceView source
class FillPdfContextManager implements FillPdfContextManagerInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* {@inheritdoc}
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FillPdfContextManager:: |
protected | property | The entity type manager. | |
FillPdfContextManager:: |
public | function |
Loads the entities specified in $context['entity_ids']. Overrides FillPdfContextManagerInterface:: |
|
FillPdfContextManager:: |
public | function |