You are here

protected function CreateHtmlRouteProvider::addPageRoute in Entity API 8.0

Returns the add page route.

Built only for entity types that have bundles.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.

Return value

\Symfony\Component\Routing\Route|null The generated route, if available.

2 calls to CreateHtmlRouteProvider::addPageRoute()
AdminCreateHtmlRouteProvider::addPageRoute in src/Routing/AdminCreateHtmlRouteProvider.php
Returns the add page route.
CreateHtmlRouteProvider::getRoutes in src/Routing/CreateHtmlRouteProvider.php
Provides routes for entities.
1 method overrides CreateHtmlRouteProvider::addPageRoute()
AdminCreateHtmlRouteProvider::addPageRoute in src/Routing/AdminCreateHtmlRouteProvider.php
Returns the add page route.

File

src/Routing/CreateHtmlRouteProvider.php, line 52
Contains \Drupal\entity\Routing\CreateHtmlRouteProvider.

Class

CreateHtmlRouteProvider
Provides HTML routes for creating entities.

Namespace

Drupal\entity\Routing

Code

protected function addPageRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('add-page') && $entity_type
    ->getKey('bundle')) {
    $route = new Route($entity_type
      ->getLinkTemplate('add-page'));
    $route
      ->setDefault('_controller', '\\Drupal\\entity\\Controller\\EntityCreateController::addPage');
    $route
      ->setDefault('_title_callback', '\\Drupal\\entity\\Controller\\EntityCreateController::addPageTitle');
    $route
      ->setDefault('entity_type_id', $entity_type
      ->id());
    $route
      ->setRequirement('_entity_create_access', $entity_type
      ->id());
    return $route;
  }
}