Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NodeEntityTranslation.php

function NodeEntityTranslation::prepareRow

Overrides SourcePluginBase::prepareRow

File

core/modules/node/src/Plugin/migrate/source/d7/NodeEntityTranslation.php, line 80

Class

NodeEntityTranslation
Drupal 7 node entity translations source from database.

Namespace

Drupal\node\Plugin\migrate\source\d7

Code

public function prepareRow(Row $row) {
    $nid = $row->getSourceProperty('entity_id');
    $vid = $row->getSourceProperty('revision_id');
    $type = $row->getSourceProperty('type');
    $language = $row->getSourceProperty('language');
    // Get Field API field values.
    foreach ($this->getFields('node', $type) as $field_name => $field) {
        // Ensure we're using the right language if the entity is translatable.
        $field_language = $field['translatable'] ? $language : NULL;
        $row->setSourceProperty($field_name, $this->getFieldValues('node', $field_name, $nid, $vid, $field_language));
    }
    // If the node title was replaced by a real field using the Drupal 7 Title
    // module, use the field value instead of the node title.
    if ($this->moduleExists('title')) {
        $title_field = $row->getSourceProperty('title_field');
        if (isset($title_field[0]['value'])) {
            $row->setSourceProperty('title', $title_field[0]['value']);
        }
    }
    return parent::prepareRow($row);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal