You are here

public function EckRoutes::routes in Entity Construction Kit (ECK) 8

1 string reference to 'EckRoutes::routes'
eck.routing.yml in ./eck.routing.yml
eck.routing.yml

File

src/Routing/EckRoutes.php, line 19

Class

EckRoutes
Defines dynamic routes.

Namespace

Drupal\eck\Routing

Code

public function routes() {
  $routeCollection = new RouteCollection();

  /** @var \Drupal\eck\Entity\EckEntityType $entityType */
  foreach (EckEntityType::loadMultiple() as $entityType) {
    $entityTypeId = $entityType
      ->id();
    $entityTypeLabel = $entityType
      ->label();
    $routeCollection
      ->add("eck.entity.{$entityTypeId}.list", $this
      ->createListRoute($entityTypeId, $entityTypeLabel));
    $routeCollection
      ->add("eck.entity.{$entityTypeId}_type.list", $this
      ->createBundleListRoute($entityTypeId, $entityTypeLabel));
    $routeCollection
      ->add("eck.entity.{$entityTypeId}_type.add", $this
      ->createAddBundleRoute($entityTypeId, $entityTypeLabel));
    $routeCollection
      ->add("entity.{$entityTypeId}_type.edit_form", $this
      ->createEditBundleRoute($entityTypeId, $entityTypeLabel));
    $routeCollection
      ->add("entity.{$entityTypeId}_type.delete_form", $this
      ->createDeleteBundleRoute($entityTypeId, $entityTypeLabel));
  }
  return $routeCollection;
}