You are here

class PathFieldProcessor in Translation Management Tool 8

Field processor for the metatags field.

Hierarchy

Expanded class hierarchy of PathFieldProcessor

1 file declares its use of PathFieldProcessor
tmgmt_content.module in sources/content/tmgmt_content.module
Source plugin for the Translation Management system that handles entities.

File

sources/content/src/PathFieldProcessor.php, line 13

Namespace

Drupal\tmgmt_content
View source
class PathFieldProcessor extends DefaultFieldProcessor {

  /**
   * {@inheritdoc}
   */
  public function extractTranslatableData(FieldItemListInterface $field) {
    $data = parent::extractTranslatableData($field);
    foreach (Element::children($data) as $key) {

      // If pathauto is enabled, do not attempt to translate the path, pathauto
      // will deal with it on the translation.
      if ($field instanceof PathautoFieldItemList && $field->pathauto == PathautoState::CREATE) {
        if (!empty($data[$key]['alias']['#translate'])) {
          $data[$key]['alias']['#translate'] = FALSE;
        }
      }
      if (!empty($data[$key]['langcode']['#translate'])) {
        $data[$key]['langcode']['#translate'] = FALSE;
      }
    }
    return $data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DefaultFieldProcessor::handleFormat protected function Handles adjusting the field item data if a format was detected.
DefaultFieldProcessor::setTranslations public function Process the translated data for this field back into a structure that can be saved by the content entity. Overrides FieldProcessorInterface::setTranslations 1
DefaultFieldProcessor::shouldTranslateProperty protected function Returns whether the property should be translated or not.
PathFieldProcessor::extractTranslatableData public function Extracts the translatatable data structure from the given field. Overrides DefaultFieldProcessor::extractTranslatableData