You are here

public static function CertificateConfigForm::getCertificateTemplateOptions in Certificate 4.x

Return a list of certificate templates suitable as options in a select list

2 calls to CertificateConfigForm::getCertificateTemplateOptions()
CertificateConfigForm::buildForm in src/Form/CertificateConfigForm.php
Form constructor.
certificate_get_certificate_options in ./certificate.module
Helper to return a list of certificate templates suitable as options in a select list

File

src/Form/CertificateConfigForm.php, line 119

Class

CertificateConfigForm
Class CertificateConfigForm.

Namespace

Drupal\certificate\Form

Code

public static function getCertificateTemplateOptions() {
  $options = [
    '-1' => t('- prevent certificate -'),
  ];
  $certificates = Drupal::entityTypeManager()
    ->getStorage('certificate_template')
    ->loadMultiple();
  foreach ($certificates as $cid => $cert_ent) {
    $options[$cert_ent
      ->get('cid')->value] = $cert_ent
      ->label();
  }
  return $options;
}