You are here

public function ContributorPropertiesService::getCategories 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::getCategories()

Get list of contributor categories.

Return value

array Contributor categories.

Overrides ContributorPropertiesServiceInterface::getCategories

1 call to ContributorPropertiesService::getCategories()
ContributorPropertiesService::getDefaultCategory in modules/bibcite_entity/src/ContributorPropertiesService.php
Get first element of category list.

File

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

Class

ContributorPropertiesService
Class ContributorPropertiesService.

Namespace

Drupal\bibcite_entity

Code

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

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