You are here

public function Exporter::processMetaTagFields in GatherContent 8.5

Processes meta fields.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: Entity object.

string $localFieldName: Field name.

bool $isTranslatable: Translatable bool.

string $language: Language string.

Return value

string Returns value.

1 call to Exporter::processMetaTagFields()
Exporter::processFields in gathercontent_upload/src/Export/Exporter.php
Processes field data.

File

gathercontent_upload/src/Export/Exporter.php, line 475

Class

Exporter
Class for handling import/update logic from GatherContent to Drupal.

Namespace

Drupal\gathercontent_upload\Export

Code

public function processMetaTagFields(EntityInterface $entity, string $localFieldName, bool $isTranslatable, string $language) {
  $fieldName = $this->metatag
    ->getFirstMetatagField($entity
    ->getEntityTypeId(), $entity
    ->bundle());
  if ($isTranslatable && $entity
    ->hasTranslation($language)) {
    $currentValue = unserialize($entity
      ->getTranslation($language)->{$fieldName}->value);
  }
  else {
    $currentValue = unserialize($entity->{$fieldName}->value);
  }
  return $currentValue[$localFieldName] ?? '';
}