You are here

protected function CreateHtmlRouteProvider::addFormRoute in Entity API 8.0

Returns the add form route.

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::addFormRoute()
AdminCreateHtmlRouteProvider::addFormRoute in src/Routing/AdminCreateHtmlRouteProvider.php
Returns the add form route.
CreateHtmlRouteProvider::getRoutes in src/Routing/CreateHtmlRouteProvider.php
Provides routes for entities.
1 method overrides CreateHtmlRouteProvider::addFormRoute()
AdminCreateHtmlRouteProvider::addFormRoute in src/Routing/AdminCreateHtmlRouteProvider.php
Returns the add form route.

File

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

Class

CreateHtmlRouteProvider
Provides HTML routes for creating entities.

Namespace

Drupal\entity\Routing

Code

protected function addFormRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('add-form')) {
    $route = new Route($entity_type
      ->getLinkTemplate('add-form'));
    $route
      ->setDefault('_controller', '\\Drupal\\entity\\Controller\\EntityCreateController::addForm');
    $route
      ->setDefault('_title_callback', '\\Drupal\\entity\\Controller\\EntityCreateController::addFormTitle');
    $route
      ->setDefault('entity_type_id', $entity_type
      ->id());
    $route
      ->setRequirement('_entity_create_access', $entity_type
      ->id());
    return $route;
  }
}