You are here

public function CertificateMapping::label in Certificate 4.x

Gets the label of the entity.

Return value

string|null The label of the entity, or NULL if there is no label defined.

Overrides ContentEntityBase::label

File

src/Entity/CertificateMapping.php, line 112

Class

CertificateMapping
Defines the credit mapping type entity class.

Namespace

Drupal\certificate\Entity

Code

public function label() {
  $cid = $this
    ->get('cid')->value;
  $certificate_label = $cid !== '-1' ? CertificateTemplate::load($cid)
    ->label() : '';
  $action = $cid !== '-1' ? t('awards certificate') : ($cid < 0 ? t('prevents awarding') : '');
  $opts = [
    '%value' => $this
      ->get('map_value')->value,
    '@action' => $action,
    '%certificate' => $certificate_label,
  ];
  $label = t('%value @action %certificate', $opts);
  return $label;
}