getEntityTypeId(); if (($entity instanceof ContentEntityInterface && $entity->isDefaultRevision()) || !$entity->getEntityType()->isRevisionable()) { $build['#contextual_links'][$entity_type_id] = [ 'route_parameters' => [ $entity_type_id => $entity->id() ], ]; } else { $build['#contextual_links'][$entity_type_id . '_revision'] = [ 'route_parameters' => [ $entity_type_id => $entity->id(), $entity_type_id . '_revision' => $entity->getRevisionId(), ], ]; } } }