You are here

public function MandrillActivityForm::fieldmapOptions in Mandrill 8

Return all possible Drupal properties for a given entity type.

Parameters

string $entity_type: Name of entity whose properties to list.

string $entity_bundle: Entity bundle to get properties for.

Return value

array List of entities that can be used as an #options list.

1 call to MandrillActivityForm::fieldmapOptions()
MandrillActivityForm::form in modules/mandrill_activity/src/Form/MandrillActivityForm.php
Gets the actual form array to be built.

File

modules/mandrill_activity/src/Form/MandrillActivityForm.php, line 228
Contains \Drupal\mandrill_activity\Form\MandrillActivityForm.

Class

MandrillActivityForm
Form controller for the MandrillActivity entity edit form.

Namespace

Drupal\mandrill_activity\Form

Code

public function fieldmapOptions($entity_type, $entity_bundle = NULL) {
  $options = array(
    '' => t('-- Select --'),
  );
  $fields = \Drupal::service('entity_field.manager')
    ->getFieldMap();
  if (isset($fields[$entity_type])) {
    foreach ($fields[$entity_type] as $key => $field) {

      // Limit to email fields.
      if ($field['type'] == 'email') {

        // Check this field appears in the selected entity bundle.
        if (isset($field['bundles'][$entity_bundle])) {
          $options[$key] = $key;
        }
      }
    }
  }
  return $options;
}