You are here

public function LoginDestination::viewTriggers in Login Destination 8

Same name and namespace in other branches
  1. 8.2 src/Entity/LoginDestination.php \Drupal\login_destination\Entity\LoginDestination::viewTriggers()

Prepare list of triggers for displaying.

Return value

string HTML view for list of triggers.

Overrides LoginDestinationInterface::viewTriggers

File

src/Entity/LoginDestination.php, line 213

Class

LoginDestination
Defines a login destination configuration entity.

Namespace

Drupal\login_destination\Entity

Code

public function viewTriggers() {
  $items = [];
  foreach ($this->triggers as $trigger) {
    if (empty($trigger)) {
      continue;
    }
    switch ($trigger) {
      case LoginDestination::TRIGGER_REGISTRATION:
        $items[] = t('Registration');
        break;
      case LoginDestination::TRIGGER_LOGIN:
        $items[] = t('Login');
        break;
      case LoginDestination::TRIGGER_ONE_TIME_LOGIN:
        $items[] = t('One-time login link');
        break;
      case LoginDestination::TRIGGER_LOGOUT:
        $items[] = t('Logout');
        break;
    }
  }
  return $this
    ->renderItemList($items, t('All triggers'));
}