You are here

MegaMenuList.php in The Better Mega Menu 8

Same filename and directory in other branches
  1. 2.x src/Controller/MegaMenuList.php

File

src/Controller/MegaMenuList.php
View source
<?php

namespace Drupal\tb_megamenu\Controller;

use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\system\Entity\Menu;

/**
 * Provides a listing of MegaMenuConfig entities.
 */
class MegaMenuList extends ConfigEntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['menu'] = $this
      ->t('Menu Name');
    $header['label'] = $this
      ->t('Menu Title');
    $header['theme'] = $this
      ->t('Theme Name');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {
    $menu_info = Menu::load($entity->menu);
    $row['menu'] = $entity->menu;
    $row['label'] = $menu_info !== NULL ? $menu_info
      ->label() : "MISSING MENU! Was it deleted?";
    $row['theme'] = $entity->theme;
    return $row + parent::buildRow($entity);
  }

}

Classes

Namesort descending Description
MegaMenuList Provides a listing of MegaMenuConfig entities.