You are here

class FillPdfContextManager in FillPDF 8.4

Same name and namespace in other branches
  1. 5.0.x src/Service/FillPdfContextManager.php \Drupal\fillpdf\Service\FillPdfContextManager

Helper class to load entities from a FillPDF context array.

Hierarchy

Expanded class hierarchy of FillPdfContextManager

1 string reference to 'FillPdfContextManager'
fillpdf.services.yml in ./fillpdf.services.yml
fillpdf.services.yml
1 service uses FillPdfContextManager
fillpdf.context_manager in ./fillpdf.services.yml
Drupal\fillpdf\Service\FillPdfContextManager

File

src/Service/FillPdfContextManager.php, line 11

Namespace

Drupal\fillpdf\Service
View 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

Namesort descending Modifiers Type Description Overrides
FillPdfContextManager::$entityTypeManager protected property The entity type manager.
FillPdfContextManager::loadEntities public function Loads the entities specified in $context['entity_ids']. Overrides FillPdfContextManagerInterface::loadEntities
FillPdfContextManager::__construct public function