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;
}
doc_Drupal
2016-10-29 08:55:25
Comments
Leave a Comment

Please login to continue.