You are here

public function RealisticDummyContentFieldModifier::getFields in Realistic Dummy Content 3.x

Same name and namespace in other branches
  1. 8.2 api/src/includes/RealisticDummyContentFieldModifier.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentFieldModifier::getFields()
  2. 7.2 api/src/includes/RealisticDummyContentFieldModifier.php \Drupal\realistic_dummy_content_api\includes\RealisticDummyContentFieldModifier::getFields()

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

Return value

array An array of RealisticDummyContentAttribute objects, keyed by attribute name, e.g. title => [RealisticDummyContentAttribute], field_image => [RealisticDummyContentAttribute]

2 calls to RealisticDummyContentFieldModifier::getFields()
RealisticDummyContentFieldModifier::getAttributes in api/src/includes/RealisticDummyContentFieldModifier.php
Returns all fields and properties.
RealisticDummyContentFieldModifier::getProperties in api/src/includes/RealisticDummyContentFieldModifier.php
Get properties for the entity, for example user's picture or node's name.

File

api/src/includes/RealisticDummyContentFieldModifier.php, line 65

Class

RealisticDummyContentFieldModifier
Field modifier class.

Namespace

Drupal\realistic_dummy_content_api\includes

Code

public function getFields() {
  $modifiable_fields = [];
  $type = $this
    ->getType();
  $bundle = $this
    ->getBundle();

  // Get _all_ defined fields. This should return an associative array.
  $fields = Framework::instance()
    ->fieldInfoFields();
  foreach ($fields as $field => $info) {
    if (isset($info['bundles'][$type]) && is_array($info['bundles'][$type]) && in_array($bundle, $info['bundles'][$type]) && $this
      ->filter($field)) {
      $this
        ->addModifier($modifiable_fields, 'field', $field);
    }
  }
  return $modifiable_fields;
}