You are here

public function ContributorPropertiesService::getRoles in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/ContributorPropertiesService.php \Drupal\bibcite_entity\ContributorPropertiesService::getRoles()

Get list of contributor roles.

Return value

array Contributor roles.

Overrides ContributorPropertiesServiceInterface::getRoles

1 call to ContributorPropertiesService::getRoles()
ContributorPropertiesService::getDefaultRole in modules/bibcite_entity/src/ContributorPropertiesService.php
Get first element of role list.

File

modules/bibcite_entity/src/ContributorPropertiesService.php, line 105

Class

ContributorPropertiesService
Class ContributorPropertiesService.

Namespace

Drupal\bibcite_entity

Code

public function getRoles() {
  if (!isset($this->rolesList)) {
    $entities = $this->entityTypeManager
      ->getStorage('bibcite_contributor_role')
      ->loadMultiple();
    uasort($entities, [
      $this,
      'sortByWeightProperty',
    ]);
    $this->rolesList = array_map(function ($entity) {

      /** @var \Drupal\Core\Entity\EntityInterface $entity */
      return $entity
        ->label();
    }, $entities);
  }
  return $this->rolesList;
}