You are here

public function InvoiceItemTypesAdminController::adminPage in Commerce Invoice 8.2

Handles base route for the field UI.

Field UI needs some base route to attach its routes to.

Return value

array The page content.

1 string reference to 'InvoiceItemTypesAdminController::adminPage'
commerce_invoice.routing.yml in ./commerce_invoice.routing.yml
commerce_invoice.routing.yml

File

src/Controller/InvoiceItemTypesAdminController.php, line 77

Class

InvoiceItemTypesAdminController
Provides the invoice item type admin controller.

Namespace

Drupal\commerce_invoice\Controller

Code

public function adminPage() {
  $entity_type = $this->entityTypeManager
    ->getDefinition('commerce_invoice_item');
  $entity_bundle_info = $this->entityTypeBundleInfo
    ->getBundleInfo('commerce_invoice_item');
  $build = [];
  $build['table'] = [
    '#type' => 'table',
    '#header' => [
      $this
        ->t('Name'),
      $this
        ->t('Description'),
      $this
        ->t('Operations'),
    ],
    '#rows' => [],
    '#empty' => $this
      ->t('There are no @label yet.', [
      '@label' => $entity_type
        ->getPluralLabel(),
    ]),
  ];
  foreach ($entity_bundle_info as $bundle_name => $bundle_info) {
    $build['table']['#rows'][$bundle_name] = [
      'name' => [
        'data' => $bundle_info['label'],
      ],
      'description' => [
        'data' => $bundle_info['description'] ?? '',
      ],
      'operations' => [
        'data' => $this
          ->buildOperations($bundle_name),
      ],
    ];
  }
  return $build;
}