protected function LingotekContentTranslationService::includeMetadata in Lingotek Translation 3.2.x
Same name and namespace in other branches
- 8.2 src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
- 4.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
- 3.0.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
- 3.1.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
- 3.3.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
- 3.4.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
- 3.5.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
- 3.6.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
- 3.7.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
- 3.8.x src/LingotekContentTranslationService.php \Drupal\lingotek\LingotekContentTranslationService::includeMetadata()
Embeds the metadata for being uploaded.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.
$data: The array of data.
1 call to LingotekContentTranslationService::includeMetadata()
- LingotekContentTranslationService::getSourceData in src/
LingotekContentTranslationService.php - Returns the source data that will be uploaded to the Lingotek service.
File
- src/
LingotekContentTranslationService.php, line 1679
Class
- LingotekContentTranslationService
- Service for managing Lingotek content translations.
Namespace
Drupal\lingotekCode
protected function includeMetadata(ContentEntityInterface &$entity, &$data, $includeIntelligenceMetadata = TRUE) {
$data['_lingotek_metadata']['_entity_type_id'] = $entity
->getEntityTypeId();
$data['_lingotek_metadata']['_entity_id'] = $entity
->id();
$data['_lingotek_metadata']['_entity_revision'] = $entity
->getRevisionId();
if ($includeIntelligenceMetadata) {
/** @var \Drupal\lingotek\LingotekIntelligenceMetadataInterface $intelligenceService */
$intelligenceService = \Drupal::service('lingotek.intelligence');
if ($entity
->id()) {
if ($entity->lingotek_metadata && $entity->lingotek_metadata->entity) {
$profile = $this->lingotekConfiguration
->getEntityProfile($entity);
}
else {
$profile = NULL;
}
$domain = \Drupal::request()
->getSchemeAndHttpHost();
$author_name = '';
$author_email = '';
if (method_exists($entity, 'getOwner')) {
/** @var \Drupal\user\UserInterface $user */
$user = $entity
->getOwner();
if ($user !== NULL && $user instanceof UserInterface) {
$author_name = $user
->getDisplayName();
$author_email = $user
->getEmail();
}
}
$intelligenceService
->setProfile($profile);
$data['_lingotek_metadata']['_intelligence']['external_document_id'] = $entity
->id();
$data['_lingotek_metadata']['_intelligence']['content_type'] = $entity
->getEntityTypeId() . ' - ' . $entity
->bundle();
// Check if we have permission to send these
if ($intelligenceService
->getBaseDomainPermission()) {
$data['_lingotek_metadata']['_intelligence']['domain'] = $domain;
}
if ($intelligenceService
->getReferenceUrlPermission()) {
$data['_lingotek_metadata']['_intelligence']['reference_url'] = $entity
->hasLinkTemplate('canonical') ? $entity
->toUrl()
->setAbsolute(TRUE)
->toString() : NULL;
}
if ($intelligenceService
->getAuthorPermission()) {
$data['_lingotek_metadata']['_intelligence']['author_name'] = $author_name;
}
if ($intelligenceService
->getAuthorPermission() && $intelligenceService
->getAuthorEmailPermission() && $intelligenceService
->getContactEmailForAuthorPermission() && $intelligenceService
->getContactEmailPermission()) {
$data['_lingotek_metadata']['_intelligence']['author_email'] = $intelligenceService
->getContactEmail();
}
if ($intelligenceService
->getAuthorPermission() && $intelligenceService
->getAuthorEmailPermission() && (!$intelligenceService
->getContactEmailForAuthorPermission() || !$intelligenceService
->getContactEmailPermission())) {
$data['_lingotek_metadata']['_intelligence']['author_email'] = $author_email;
}
if ($intelligenceService
->getBusinessUnitPermission()) {
$data['_lingotek_metadata']['_intelligence']['business_unit'] = $intelligenceService
->getBusinessUnit();
}
if ($intelligenceService
->getBusinessDivisionPermission()) {
$data['_lingotek_metadata']['_intelligence']['business_division'] = $intelligenceService
->getBusinessDivision();
}
if ($intelligenceService
->getCampaignIdPermission()) {
$data['_lingotek_metadata']['_intelligence']['campaign_id'] = $intelligenceService
->getCampaignId();
}
if ($intelligenceService
->getCampaignRatingPermission()) {
$data['_lingotek_metadata']['_intelligence']['campaign_rating'] = $intelligenceService
->getCampaignRating();
}
if ($intelligenceService
->getChannelPermission()) {
$data['_lingotek_metadata']['_intelligence']['channel'] = $intelligenceService
->getChannel();
}
if ($intelligenceService
->getContactNamePermission()) {
$data['_lingotek_metadata']['_intelligence']['contact_name'] = $intelligenceService
->getContactName();
}
if ($intelligenceService
->getContactEmailPermission()) {
$data['_lingotek_metadata']['_intelligence']['contact_email'] = $intelligenceService
->getContactEmail();
}
if ($intelligenceService
->getContentDescriptionPermission()) {
$data['_lingotek_metadata']['_intelligence']['content_description'] = $intelligenceService
->getContentDescription();
}
if ($intelligenceService
->getExternalStyleIdPermission()) {
$data['_lingotek_metadata']['_intelligence']['external_style_id'] = $intelligenceService
->getExternalStyleId();
}
if ($intelligenceService
->getPurchaseOrderPermission()) {
$data['_lingotek_metadata']['_intelligence']['purchase_order'] = $intelligenceService
->getPurchaseOrder();
}
if ($intelligenceService
->getRegionPermission()) {
$data['_lingotek_metadata']['_intelligence']['region'] = $intelligenceService
->getRegion();
}
}
}
}