config_entity_revisions.inc in Config Entity Revisions 8.2
Helper functions.
File
config_entity_revisions.incView source
<?php
/**
* @file
* Helper functions.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
/**
* Helper to get revisions operations available for an entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity under consideration.
*
* @return array
* The operations available.
*/
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;
}
Functions
Name | Description |
---|---|
config_entity_revisions_entity_operation_helper | Helper to get revisions operations available for an entity. |