You are here

public function EckContentController::addPage in Entity Construction Kit (ECK) 8

Displays add content link for available entity types.

Parameters

\Drupal\eck\EckEntityTypeInterface $eck_entity_type: The request parameters.

Return value

array The output as a renderable array.

1 string reference to 'EckContentController::addPage'
eck.routing.yml in ./eck.routing.yml
eck.routing.yml

File

src/Controller/EckContentController.php, line 55

Class

EckContentController
Provides a content controller for entities.

Namespace

Drupal\eck\Controller

Code

public function addPage(EckEntityTypeInterface $eck_entity_type) {
  $content = [];
  $bundleStorage = $this
    ->getBundleStorage($eck_entity_type);

  /** @var \Drupal\eck\Entity\EckEntityBundle $bundle */
  foreach ($bundleStorage
    ->loadMultiple() as $bundle) {
    if ($this
      ->entityTypeManager()
      ->getAccessControlHandler($eck_entity_type
      ->id())
      ->createAccess($bundle->type)) {
      $content[$bundle->type] = $bundle;
    }
  }
  return [
    '#theme' => 'eck_content_add_list',
    '#content' => $content,
    '#entity_type' => [
      'id' => $eck_entity_type
        ->id(),
      'label' => $eck_entity_type
        ->label(),
    ],
  ];
}