You are here

public static function EntityCheck::getEntityTypesList in Entity Update 8

Same name and namespace in other branches
  1. 2.0.x src/EntityCheck.php \Drupal\entity_update\EntityCheck::getEntityTypesList()

Get entity types list.

Parameters

string $type: The entity type id.

bool $print: Print to the drush terminal.

Return value

array The table (Renderer array).

3 calls to EntityCheck::getEntityTypesList()
drush_entity_update_entity_check in ./entity_update.drush.inc
Call back function of entity-check.
EntityList::buildForm in src/Form/EntityList.php
Form constructor.
EntityUpdateStatus::entityTypes in src/Controller/EntityUpdateStatus.php
Get entity types list.

File

src/EntityCheck.php, line 21

Class

EntityCheck
EntityCheck Main Class.

Namespace

Drupal\entity_update

Code

public static function getEntityTypesList($type = NULL, $print = TRUE) {
  $itmes_list = \Drupal::entityTypeManager()
    ->getDefinitions();
  $table = [
    '#theme' => 'table',
    '#cache' => [
      'max-age' => 0,
    ],
    '#caption' => 'Entity types list',
    '#header' => [
      'Type ID',
      'Type',
      'Name',
    ],
    '#rows' => [],
  ];
  foreach ($itmes_list as $itme_name => $item_object) {

    // Excluse if filtred by type.
    if ($type && strstr($itme_name, $type) === FALSE) {
      continue;
    }
    $table['#rows'][] = [
      $itme_name,
      $item_object
        ->getGroup(),
      $item_object
        ->getLabel(),
    ];
  }

  // Print table.
  if ($print) {
    EntityUpdatePrint::drushPrintTable($table);
  }
  return $table;
}