You are here

protected function GroupContentRouteProvider::getAddFormRoute in Group 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/Routing/GroupContentRouteProvider.php \Drupal\group\Entity\Routing\GroupContentRouteProvider::getAddFormRoute()

Gets 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.

Overrides DefaultHtmlRouteProvider::getAddFormRoute

File

src/Entity/Routing/GroupContentRouteProvider.php, line 50

Class

GroupContentRouteProvider
Provides routes for group content.

Namespace

Drupal\group\Entity\Routing

Code

protected function getAddFormRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('add-form')) {
    $route = new Route($entity_type
      ->getLinkTemplate('add-form'));
    $route
      ->setDefaults([
      '_controller' => '\\Drupal\\group\\Entity\\Controller\\GroupContentController::addForm',
      // @todo Let forms set title?
      '_title_callback' => '\\Drupal\\group\\Entity\\Controller\\GroupContentController::addFormTitle',
    ])
      ->setRequirement('_group_content_create_access', 'TRUE')
      ->setOption('_group_operation_route', TRUE);
    return $route;
  }
}