You are here

function FieldModifier::GetFields in Realistic Dummy Content 8

Get fields for the entity, for example body or field_image.

Return value

An empty array is returned in case of an error. An array of Attribute objects, keyed by attribute name, e.g. title => [\Drupal\realistic_dummy_content_api\attributes\Attribute], field_image => [...]

1 call to FieldModifier::GetFields()
FieldModifier::GetAttributes in api/src/manipulators/FieldModifier.php
Returns all fields and properties.

File

api/src/manipulators/FieldModifier.php, line 75
Define autoload class.

Class

FieldModifier
Field modifier class.

Namespace

Drupal\realistic_dummy_content_api\manipulators

Code

function GetFields() {
  try {
    $entity = $this
      ->GetEntity();

    // We now have an entity object, for example \Drupal\node\Entity\Node
    $modifiable_fields = $entity
      ->getFields();

    // $fields is now an array of things like nid, uuid, created, body,
    // field_image, etc.
    foreach ($modifiable_fields as $field => $object) {
      $this
        ->AddModifier($modifiable_fields, 'field_config', $field);
    }
    return $modifiable_fields;
  } catch (\Exception $e) {
    return array();
  }
}