function EntityLinkSuggestionsController::computeGroup

Computers a suggestion group.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The suggested entity for which to compute the group.

Return value

string A suggestion group.

File

core/modules/ckeditor5/src/Controller/EntityLinkSuggestionsController.php, line 287

Class

EntityLinkSuggestionsController
Returns responses for entity link suggestions autocomplete route.

Namespace

Drupal\ckeditor5\Controller

Code

protected function computeGroup(EntityInterface $entity) : string {
  // If the entity type does not have bundles, the group is very simple.
  if ($entity->getEntityType()
    ->getBundleEntityType() === NULL) {
    return $entity->getEntityType()
      ->getLabel();
  }
  $bundles = $this->entityTypeBundleInfo
    ->getBundleInfo($entity->getEntityTypeId());
  return $entity->getEntityType()
    ->getLabel() . ' - ' . $bundles[$entity->bundle()]['label'];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.