DefaultHtmlRouteProvider::getAddPageRoute

protected DefaultHtmlRouteProvider::getAddPageRoute(EntityTypeInterface $entity_type)

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.

File

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

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;
  }
}
doc_Drupal
2016-10-29 09:01:43
Comments
Leave a Comment

Please login to continue.