public function AbstractEntityFormModesFactory::pageTitle in Form mode manager 8.2
The _title_callback for the entity.add routes.
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.
string $operation: Name of current context operation to display title (create/edit).
Return value
string The page title.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
2 calls to AbstractEntityFormModesFactory::pageTitle()
File
- src/
AbstractEntityFormModesFactory.php, line 255
Class
- AbstractEntityFormModesFactory
- Abstract Factory to generate object used by routing of Form Mode Manager.
Namespace
Drupal\form_mode_managerCode
public function pageTitle(RouteMatchInterface $route_match, $operation) {
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity_properties = $this
->getEntityTypeFromRouteMatch($route_match);
$form_mode_label = $route_match
->getRouteObject()
->getOption('parameters')['form_mode']['label'];
/** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
$entity_type = $this->entityTypeManager
->getStorage($entity_properties['entity_type_id'])
->getEntityType();
$name = strtolower($entity_type
->getLabel());
if (!empty($entity_properties['bundle'])) {
$name = $entity_properties['bundle'];
}
return $this
->t('@op @name as @form_mode_label', [
'@name' => $name,
'@form_mode_label' => $form_mode_label,
'@op' => $operation,
]);
}