You are here

public function PrintableEntityManager::getCompatibleEntities in Printer and PDF versions for Drupal 8+ 2.x

Same name and namespace in other branches
  1. 8 src/PrintableEntityManager.php \Drupal\printable\PrintableEntityManager::getCompatibleEntities()

Get the entities that Printable can generate hardcopies for.

Return value

array An array of entity definitions keyed by the entity type.

Overrides PrintableEntityManagerInterface::getCompatibleEntities

1 call to PrintableEntityManager::getCompatibleEntities()
PrintableEntityManager::getPrintableEntities in src/PrintableEntityManager.php
Get the entities that printable is available for.

File

src/PrintableEntityManager.php, line 79

Class

PrintableEntityManager
Helper class for the printable module.

Namespace

Drupal\printable

Code

public function getCompatibleEntities() {

  // If the entities are yet to be populated, get the entity definitions from
  // the entity manager.
  if (empty($this->compatibleEntities)) {
    foreach ($this->entityTypeManager
      ->getDefinitions() as $entity_type => $entity_definition) {

      // If this entity has a render controller, it has a printable version.
      if ($entity_definition
        ->hasHandlerClass('view_builder')) {
        $this->compatibleEntities[$entity_type] = $entity_definition;
      }
    }
  }
  return $this->compatibleEntities;
}