You are here

public function Mp3playerController::mp3player_player_list in MP3 Player 8

1 string reference to 'Mp3playerController::mp3player_player_list'
mp3player.routing.yml in ./mp3player.routing.yml
mp3player.routing.yml

File

src/Controller/Mp3playerController.php, line 11

Class

Mp3playerController

Namespace

Drupal\mp3player\Controller

Code

public function mp3player_player_list() {
  $header = array(
    t('Player Name'),
    t('Actions'),
  );
  $rows = array();
  $players = $this
    ->mp3player_players();
  foreach ($players as $pid => $player) {
    $row = array();
    $row[] = $player['name'];
    $url = Url::fromRoute('mp3player.edit_player', array(
      'pid' => $pid,
    ));
    $row[] = \Drupal::l(t('Edit'), $url);
    if ($pid > 1) {
      $url = Url::fromRoute('mp3player.delete_player', array(
        'pid' => $pid,
      ));
      $row[] = \Drupal::l(t('Delete'), $url);
    }
    $rows[] = $row;
  }
  $output = array(
    '#type' => 'table',
    '#header' => $header,
    '#rows' => $rows,
  );
  return $output;
}