You are here

StoreListBuilder.php in Commerce Core 8.2

File

modules/store/src/StoreListBuilder.php
View source
<?php

namespace Drupal\commerce_store;

use Drupal\commerce_store\Entity\StoreType;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;

/**
 * Defines the list builder for stores.
 */
class StoreListBuilder extends EntityListBuilder {

  /**
   * {@inheritdoc}
   */
  public function buildHeader() {
    $header['name'] = $this
      ->t('Name');
    $header['type'] = $this
      ->t('Type');
    return $header + parent::buildHeader();
  }

  /**
   * {@inheritdoc}
   */
  public function buildRow(EntityInterface $entity) {

    /** @var \Drupal\commerce_store\Entity\StoreInterface $entity */
    $store_type = StoreType::load($entity
      ->bundle());
    $row['name']['data'] = [
      '#type' => 'link',
      '#title' => $entity
        ->label(),
    ] + $entity
      ->toUrl()
      ->toRenderArray();
    $row['type'] = $store_type
      ->label();
    return $row + parent::buildRow($entity);
  }

}

Classes

Namesort descending Description
StoreListBuilder Defines the list builder for stores.