You are here

function eck__entity_type__list in Entity Construction Kit (ECK) 7.3

Same name and namespace in other branches
  1. 7.2 eck.entity_type.inc \eck__entity_type__list()

Callback for the entity_type overview.

1 string reference to 'eck__entity_type__list'
eck__entity_type__menu in ./eck.entity_type.inc
Passthrough from hook_menu().

File

./eck.entity_type.inc, line 59
ENTITY TYPE

Code

function eck__entity_type__list() {
  $allowed_operations = "";
  $path = eck__entity_type__path();
  $header = array(
    t('Name'),
    array(
      'data' => t('Operations'),
      'colspan' => '1',
    ),
  );
  $rows = array();
  $entity_types = EntityType::loadAll();
  usort($entity_types, 'eck_alphabetical_cmp');
  foreach ($entity_types as $entity_type) {

    // Check that the user has permissions to operate on the entity types.
    $actions = array(
      "update" => "edit",
      "delete" => "delete",
    );
    foreach ($actions as $action => $menu) {
      if (eck_access($action, 'entity_type', $entity_type)) {
        $allowed_operations = isset($allowed_operations) ? $allowed_operations . " | " : "";
        $allowed_operations .= l(t("@menu", array(
          "@menu" => $menu,
        )), "{$path}/{$entity_type->name}/{$menu}");
      }
    }
    if (eck_access("list", "bundle") || eck_access("list", "bundle", $entity_type)) {
      $link = "{$path}/{$entity_type->name}";
      $link_text = t("@entity_type_label", array(
        "@entity_type_label" => $entity_type->label,
      ));
      $rows[] = array(
        l($link_text, $link),
        $allowed_operations,
      );
    }
    else {
      $rows[] = array(
        t("@entity_type_label", array(
          "@entity_type_label" => $entity_type->label,
        )),
        $allowed_operations,
      );
    }
    $allowed_operations = NULL;
  }
  $build['entity_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
  );
  return $build;
}