function ContentEntity::toArray
Converts an entity to an array.
Makes all IDs into flat values. All other values are returned as per $entity->toArray(), which is a nested array.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to convert.
Return value
array The entity, represented as an array.
1 call to ContentEntity::toArray()
- ContentEntity::yieldEntities in core/
modules/ migrate/ src/ Plugin/ migrate/ source/ ContentEntity.php  - Loads and yields entities, one at a time.
 
File
- 
              core/
modules/ migrate/ src/ Plugin/ migrate/ source/ ContentEntity.php, line 191  
Class
- ContentEntity
 - Source plugin to get content entities from the current version of Drupal.
 
Namespace
Drupal\migrate\Plugin\migrate\sourceCode
protected function toArray(ContentEntityInterface $entity) : array {
  $return = $entity->toArray();
  // This is necessary because the IDs must be flat. They cannot be nested for
  // the ID map.
  foreach (array_keys($this->getIds()) as $id) {
    /** @var \Drupal\Core\TypedData\Plugin\DataType\ItemList $value */
    $value = $entity->get($id);
    // Force the IDs on top of the previous values.
    $return[$id] = $value->first()
      ->getString();
  }
  return $return;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.