You are here

function config_entity_revisions_entity_operation_helper in Config Entity Revisions 8.2

Helper to get revisions operations available for an entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity under consideration.

Return value

array The operations available.

1 call to config_entity_revisions_entity_operation_helper()
contact_form_revisions_entity_operation in modules/contact_form_revisions/contact_form_revisions.module
Implements hook_entity_operations().

File

./config_entity_revisions.inc, line 20
Helper functions.

Code

function config_entity_revisions_entity_operation_helper(EntityInterface $entity) {

  // Add revisions operation and display links. The caller checks whether to do
  // this.
  $operations = [];
  $entity_type = $entity
    ->getEntityType();
  $entity_type_id = $entity_type
    ->id();
  $account = \Drupal::currentUser();
  if ($account
    ->hasPermission('administer ' . $entity_type_id . ' revisions')) {
    $operations['revisions'] = [
      'title' => t('Revisions'),
      'weight' => 30,
      'url' => Url::fromRoute("entity.{$entity_type_id}.revisions", [
        $entity_type_id => $entity
          ->id(),
      ]),
    ];
  }
  return $operations;
}