W3cubDocs

/Drupal 8

function config_translation_entity_operation

config_translation_entity_operation(EntityInterface $entity)

Implements hook_entity_operation().

File

core/modules/config_translation/config_translation.module, line 154
Configuration Translation module.

Code

function config_translation_entity_operation(EntityInterface $entity) {
  $operations = array();
  $entity_type = $entity->getEntityType();
  if ($entity_type->isSubclassOf('Drupal\Core\Config\Entity\ConfigEntityInterface') && 
    $entity->hasLinkTemplate('config-translation-overview') && 
    \Drupal::currentUser()->hasPermission('translate configuration')) {

    $link_template = 'config-translation-overview';
    if ($entity instanceof FieldConfigInterface) {
      $link_template = "config-translation-overview.{$entity->getTargetEntityTypeId()}";
    }

    $operations['translate'] = array(
      'title' => t('Translate'),
      'weight' => 50,
      'url' => $entity->urlInfo($link_template),
    );
  }

  return $operations;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!config_translation!config_translation.module/function/config_translation_entity_operation/8.1.x