protected function FieldableEntity::getFieldValues in Drupal 10
Same name and namespace in other branches
- 8 core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity::getFieldValues()
- 9 core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php \Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity::getFieldValues()
Retrieves field values for a single field of a single entity.
Typically, getFieldValues() is used in the prepareRow method of a source plugin where the return values are placed on the row source.
Parameters
string $entity_type: The entity type.
string $field: The field name.
int $entity_id: The entity ID.
int|null $revision_id: (optional) The entity revision ID.
string $language: (optional) The field language.
Return value
array The raw field values, keyed and sorted by delta.
8 calls to FieldableEntity::getFieldValues()
- Comment::prepareRow in core/modules/ comment/ src/ Plugin/ migrate/ source/ d7/ Comment.php 
- Adds additional data to the row.
- CommentEntityTranslation::prepareRow in core/modules/ comment/ src/ Plugin/ migrate/ source/ d7/ CommentEntityTranslation.php 
- Adds additional data to the row.
- Node::prepareRow in core/modules/ node/ src/ Plugin/ migrate/ source/ d7/ Node.php 
- Adds additional data to the row.
- NodeEntityTranslation::prepareRow in core/modules/ node/ src/ Plugin/ migrate/ source/ d7/ NodeEntityTranslation.php 
- Adds additional data to the row.
- Term::prepareRow in core/modules/ taxonomy/ src/ Plugin/ migrate/ source/ d7/ Term.php 
- Adds additional data to the row.
File
- core/modules/ migrate_drupal/ src/ Plugin/ migrate/ source/ d7/ FieldableEntity.php, line 74 
Class
- FieldableEntity
- Base class for D7 source plugins which need to collect field values from the Field API.
Namespace
Drupal\migrate_drupal\Plugin\migrate\source\d7Code
protected function getFieldValues($entity_type, $field, $entity_id, $revision_id = NULL, $language = NULL) {
  $table = (isset($revision_id) ? 'field_revision_' : 'field_data_') . $field;
  $query = $this
    ->select($table, 't')
    ->fields('t')
    ->condition('entity_type', $entity_type)
    ->condition('entity_id', $entity_id)
    ->condition('deleted', 0)
    ->orderBy('delta');
  if (isset($revision_id)) {
    $query
      ->condition('revision_id', $revision_id);
  }
  // Add 'language' as a query condition if it has been defined by Entity
  // Translation.
  if ($language) {
    $query
      ->condition('language', $language);
  }
  $values = [];
  foreach ($query
    ->execute() as $row) {
    foreach ($row as $key => $value) {
      $delta = $row['delta'];
      if (strpos($key, $field) === 0) {
        $column = substr($key, strlen($field) + 1);
        $values[$delta][$column] = $value;
      }
    }
  }
  return $values;
}