public function EntityCreateController::addFormTitle in Entity API 8.0
The title callback for the add form.
Parameters
string $entity_type_id: The entity type ID.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.
Return value
string The page title.
File
- src/
Controller/ EntityCreateController.php, line 171 - Contains \Drupal\entity\Controller\EntityCreateController.
Class
- EntityCreateController
- A generic controller for creating entities.
Namespace
Drupal\entity\ControllerCode
public function addFormTitle($entity_type_id, RouteMatchInterface $route_match) {
$entity_type = $this
->entityTypeManager()
->getDefinition($entity_type_id);
$bundle_key = $entity_type
->getKey('bundle');
$bundles = $this->entityTypeBundleInfo
->getBundleInfo($entity_type_id);
if ($bundle_key && count($bundles) > 1) {
$bundle_name = $route_match
->getRawParameter($bundle_key);
$title = $this
->t('Add @bundle', [
'@bundle' => $bundles[$bundle_name]['label'],
]);
}
else {
$title = $this
->t('Add @entity-type', [
'@entity-type' => $entity_type
->getLowercaseLabel(),
]);
}
return $title;
}