You are here

protected function DefaultHtmlRouteProvider::getAddPageRoute in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getAddPageRoute()
  2. 9 core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getAddPageRoute()

Gets 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 DefaultHtmlRouteProvider::getAddPageRoute()
AdminHtmlRouteProvider::getAddPageRoute in core/lib/Drupal/Core/Entity/Routing/AdminHtmlRouteProvider.php
Gets the add page route.
DefaultHtmlRouteProvider::getRoutes in core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php
Provides routes for entities.
1 method overrides DefaultHtmlRouteProvider::getAddPageRoute()
AdminHtmlRouteProvider::getAddPageRoute in core/lib/Drupal/Core/Entity/Routing/AdminHtmlRouteProvider.php
Gets the add page route.

File

core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php, line 120

Class

DefaultHtmlRouteProvider
Provides HTML routes for entities.

Namespace

Drupal\Core\Entity\Routing

Code

protected function getAddPageRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('add-page') && $entity_type
    ->getKey('bundle')) {
    $route = new Route($entity_type
      ->getLinkTemplate('add-page'));
    $route
      ->setDefault('_controller', EntityController::class . '::addPage');
    $route
      ->setDefault('_title_callback', EntityController::class . '::addTitle');
    $route
      ->setDefault('entity_type_id', $entity_type
      ->id());
    $route
      ->setRequirement('_entity_create_any_access', $entity_type
      ->id());
    return $route;
  }
}