You are here

public function FieldUiTitleController::bundle in Lightning Core 8

Same name and namespace in other branches
  1. 8.5 src/Controller/FieldUiTitleController.php \Drupal\lightning_core\Controller\FieldUiTitleController::bundle()
  2. 8.2 src/Controller/FieldUiTitleController.php \Drupal\lightning_core\Controller\FieldUiTitleController::bundle()
  3. 8.3 src/Controller/FieldUiTitleController.php \Drupal\lightning_core\Controller\FieldUiTitleController::bundle()
  4. 8.4 src/Controller/FieldUiTitleController.php \Drupal\lightning_core\Controller\FieldUiTitleController::bundle()

Title callback for certain Field UI routes.

Return value

string Either the label of the bundle affected at the current route, or the route's default title if the bundle is not known.

See also

\Drupal\lightning_core\Routing\RouteSubscriber::alterRoutes()

File

src/Controller/FieldUiTitleController.php, line 60

Class

FieldUiTitleController
Dynamically generates titles for various Field UI routes.

Namespace

Drupal\lightning_core\Controller

Code

public function bundle() {
  $route_parameters = $this->routeMatch
    ->getParameters();
  if ($route_parameters
    ->has('entity_type_id')) {

    // Determine the route parameter which contains the bundle entity,
    // assuming the entity type is bundle-able.
    $bundle = $this
      ->entityTypeManager()
      ->getDefinition($route_parameters
      ->get('entity_type_id'))
      ->getBundleEntityType();
    if ($bundle) {
      $bundle = $route_parameters
        ->get($bundle);
      if ($bundle instanceof EntityInterface) {
        return $bundle
          ->label();
      }
    }
  }
  return $this->routeMatch
    ->getRouteObject()
    ->getDefault('_title');
}