You are here

public function EckEntity::label in Entity Construction Kit (ECK) 8

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/EckEntity.php, line 98

Class

EckEntity
Defines the ECK entity.

Namespace

Drupal\eck\Entity

Code

public function label() {
  if ($this
    ->hasField('title')) {
    $title = $this
      ->get('title')
      ->first();
    if (!empty($title)) {
      return $title
        ->getString();
    }
  }
  return '';
}