You are here

public function UserRole::getSummary in Feeds 8.3

Returns the summary for a target.

Returning the summary as array is encouraged. The allowance of returning a string only exists for backwards compatibility.

Return value

string|string[] The configuration summary.

Overrides ConfigEntityReference::getSummary

File

src/Feeds/Target/UserRole.php, line 227

Class

UserRole
Defines a user role mapper.

Namespace

Drupal\feeds\Feeds\Target

Code

public function getSummary() {
  $summary = parent::getSummary();

  // Allowed roles.
  $role_names = array_intersect_key($this
    ->getRoleNames(), array_filter($this->configuration['allowed_roles']));
  if (empty($role_names)) {
    $role_names = [
      '<' . $this
        ->t('none') . '>',
    ];
  }
  $summary[] = $this
    ->t('Allowed roles: %roles', [
    '%roles' => implode(', ', $role_names),
  ]);

  // Autocreate.
  if ($this->configuration['autocreate']) {
    $summary[] = $this
      ->t('Automatically create roles');
  }
  else {
    $summary[] = $this
      ->t('Only assign existing roles');
  }

  // Revoke roles.
  if ($this->configuration['revoke_roles']) {
    $summary[] = $this
      ->t('Revoke roles: yes');
  }
  else {
    $summary[] = $this
      ->t('Revoke roles: no');
  }
  return $summary;
}