8.5.x FieldableEntity.php FieldableEntity::getFieldValues($entity_type, $field, $entity_id, $revision_id = NULL)
8.0.x FieldableEntity.php FieldableEntity::getFieldValues($entity_type, $field, $entity_id, $revision_id = NULL)
8.1.x FieldableEntity.php FieldableEntity::getFieldValues($entity_type, $field, $entity_id, $revision_id = NULL)
8.2.x FieldableEntity.php FieldableEntity::getFieldValues($entity_type, $field, $entity_id, $revision_id = NULL)
8.3.x FieldableEntity.php FieldableEntity::getFieldValues($entity_type, $field, $entity_id, $revision_id = NULL)
8.4.x FieldableEntity.php FieldableEntity::getFieldValues($entity_type, $field, $entity_id, $revision_id = NULL)
8.6.x FieldableEntity.php FieldableEntity::getFieldValues($entity_type, $field, $entity_id, $revision_id = NULL)

Retrieves field values for a single field of a single entity.

@todo Support multilingual field values.

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.

Return value

array The raw field values, keyed by delta.

4 calls to FieldableEntity::getFieldValues()
Comment::prepareRow in core/modules/comment/src/Plugin/migrate/source/d7/Comment.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.
Term::prepareRow in core/modules/taxonomy/src/Plugin/migrate/source/d7/Term.php
Adds additional data to the row.
User::prepareRow in core/modules/user/src/Plugin/migrate/source/d7/User.php
Adds additional data to the row.

File

core/modules/migrate_drupal/src/Plugin/migrate/source/d7/FieldableEntity.php, line 51

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\d7

Code

protected function getFieldValues($entity_type, $field, $entity_id, $revision_id = 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);
  if (isset($revision_id)) {
    $query
      ->condition('revision_id', $revision_id);
  }
  $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;
}