You are here

function agreement_get_agreement_options in Agreement 3.0.x

Same name and namespace in other branches
  1. 8.2 agreement.module \agreement_get_agreement_options()

Gets the agreement types for views.

Return value

array An associative array of agreement types and labels.

1 string reference to 'agreement_get_agreement_options'
agreement_views_data in ./agreement.views.inc
Implements hook_views_data().

File

./agreement.module, line 76
Agreement module code - agreement.module.

Code

function agreement_get_agreement_options() {
  $options = [];
  try {
    $agreements = \Drupal::entityTypeManager()
      ->getStorage('agreement')
      ->loadMultiple();
    foreach ($agreements as $id => $agreement) {
      $options[$agreement
        ->id()] = $agreement
        ->label();
    }
  } catch (InvalidPluginDefinitionException $e) {
    \Drupal::messenger()
      ->addError(t('Unable to load agreement types.'));
  }
  return $options;
}