You are here

function social_language_entity_operation_alter in Open Social 10.2.x

Same name and namespace in other branches
  1. 10.3.x modules/custom/social_language/social_language.module \social_language_entity_operation_alter()

Implements hook_entity_operation_alter().

File

modules/custom/social_language/social_language.module, line 56
Contains social_language.module.

Code

function social_language_entity_operation_alter(array &$operations, EntityInterface $entity) : array {

  // "Content Translations" module allows to add translations
  // to the entity that user can't edit...This cause displaying
  // the redundant operation "translate" in entity list pages.

  /* @see content_translation_translate_access() */
  if (!empty($operations['translate'])) {

    // All checks are already done in social_language_entity_operation()
    // and we need only add the last one.
    if (!$entity
      ->access('update')) {

      // Remove the operation if user can't edit entity.
      unset($operations['translate']);
    }
  }
  return $operations;
}