function EntityLinkSuggestionsController::createSuggestion

Creates a suggestion.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The matched entity.

Return value

array A suggestion object with populated entity data.

File

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

Class

EntityLinkSuggestionsController
Returns responses for entity link suggestions autocomplete route.

Namespace

Drupal\ckeditor5\Controller

Code

protected function createSuggestion(EntityInterface $entity) : array {
  return [
    'description' => $this->computeDescription($entity) ?? '',
    'entity_type_id' => $entity->getEntityTypeId(),
    'entity_uuid' => $entity->uuid(),
    'group' => $this->computeGroup($entity),
    'label' => $entity->label(),
    // Use the canonical URI as a valid fallback for the href. The
    // text_format filter will transform this to the final URL (e.g., alias).
'path' => $entity->toUrl('canonical')
      ->toString(),
  ];
}

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