You are here

public function BulkUserRegistration::getFieldNames in Bulk User Registration 8

Get CSV field names.

Return value

string[] Structured array of field names with the field names as key. Extra fields are identified by the value TRUE. Default fields have a value FALSE.

Overrides BulkUserRegistrationInterface::getFieldNames

File

src/BulkUserRegistration.php, line 105

Class

BulkUserRegistration
The BulkUserRegistration service.

Namespace

Drupal\bulk_user_registration

Code

public function getFieldNames() {
  if (count($this->fieldNames) == 0) {
    $fieldNames = [];

    // Allow modules to define extra fields that will be allowed during
    // import.
    $extraFields = $this->moduleHandler
      ->invokeAll('bulk_user_registration_extra_fields');

    // Add standard fields.
    foreach ($this
      ->getStandardFields() as $name) {
      $fieldNames[$name] = FALSE;
    }

    // Add extra fields to the set of field names and flag them as extra.
    foreach ($extraFields as $name) {
      if (!isset($fieldNames[$name])) {
        $fieldNames[$name] = TRUE;
      }
    }
    $this->fieldNames = $fieldNames;
  }
  return $this->fieldNames;
}