function DefaultHtmlRouteProvider::getAddPageRoute

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getAddPageRoute()
  2. 10 core/lib/Drupal/Core/Entity/Routing/DefaultHtmlRouteProvider.php \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider::getAddPageRoute()
  3. 11.x 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.

3 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.
TestDefaultHtmlRouteProvider::getAddPageRoute in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
Gets the add page route.
2 methods override DefaultHtmlRouteProvider::getAddPageRoute()
AdminHtmlRouteProvider::getAddPageRoute in core/lib/Drupal/Core/Entity/Routing/AdminHtmlRouteProvider.php
Gets the add page route.
TestDefaultHtmlRouteProvider::getAddPageRoute in core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.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;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.