You are here

function lingotek_test_lingotek_content_entity_get_profile in Lingotek Translation 3.4.x

Same name and namespace in other branches
  1. 8.2 tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()
  2. 4.0.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()
  3. 3.0.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()
  4. 3.1.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()
  5. 3.2.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()
  6. 3.3.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()
  7. 3.5.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()
  8. 3.6.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()
  9. 3.7.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()
  10. 3.8.x tests/modules/lingotek_test/lingotek_test.module \lingotek_test_lingotek_content_entity_get_profile()

Implements hook_lingotek_content_entity_get_profile().

If the document being uploaded is a comment, use the profile from the parent.

File

tests/modules/lingotek_test/lingotek_test.module, line 33
Provides a fake Lingotek API endpoint and other help for testing purposes.

Code

function lingotek_test_lingotek_content_entity_get_profile(ContentEntityInterface $entity, LingotekProfileInterface &$profile = NULL, $provide_default = TRUE) {
  if ($entity
    ->getEntityTypeId() === 'comment') {

    /** @var \Drupal\comment\CommentInterface $entity */
    $commented = $entity
      ->getCommentedEntity();

    /** @var \Drupal\lingotek\LingotekConfigurationServiceInterface $lingotek_config */
    $lingotek_config = \Drupal::service('lingotek.configuration');
    $profile = $lingotek_config
      ->getEntityProfile($commented, FALSE);
  }
  if ($entity
    ->getEntityTypeId() === 'node' && $entity
    ->bundle() === 'null_profile') {
    $profile = NULL;
  }
}