protected function ConnectionHtmlRouteProvider::getAddFormRoute in RedHen CRM 8
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
- modules/
redhen_connection/ src/ ConnectionHtmlRouteProvider.php, line 82
Class
- ConnectionHtmlRouteProvider
- Provides routes for Connection entities.
Namespace
Drupal\redhen_connectionCode
protected function getAddFormRoute(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('add-form')) {
$entity_type_id = $entity_type
->id();
$parameters = [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
'redhen_type' => [
'type' => 'redhen_type',
],
'entity' => [
'type' => 'entity:{redhen_type}',
],
];
$route = new Route($entity_type
->getLinkTemplate('add-form'));
$bundle_entity_type_id = $entity_type
->getBundleEntityType();
// Content entities with bundles are added via a dedicated controller.
$route
->setDefaults([
'_controller' => 'Drupal\\redhen_connection\\Controller\\ConnectionAddController::addForm',
'_title_callback' => 'Drupal\\redhen_connection\\Controller\\ConnectionAddController::getAddFormTitle',
])
->setRequirement('_entity_create_access', $entity_type_id . ':{' . $bundle_entity_type_id . '}');
$parameters[$bundle_entity_type_id] = [
'type' => 'entity:' . $bundle_entity_type_id,
];
$route
->setOption('parameters', $parameters);
return $route;
}
}