function OEmbedWidget::getValueDescription

Merges description and provider messages.

Parameters

\Drupal\Core\Field\FieldItemListInterface $items: FieldItemList containing the values to be edited.

scalar|\Stringable|\Drupal\Core\Render\RenderableInterface|array $description: The description on the form element.

Return value

string|array The description on the value child.

1 call to OEmbedWidget::getValueDescription()
OEmbedWidget::singleElementObject in core/modules/media/src/Plugin/Field/FieldWidget/OEmbedWidget.php
Returns the form for a single field widget.

File

core/modules/media/src/Plugin/Field/FieldWidget/OEmbedWidget.php, line 51

Class

OEmbedWidget
Plugin implementation of the 'oembed_textfield' widget.

Namespace

Drupal\media\Plugin\Field\FieldWidget

Code

protected function getValueDescription(FieldItemListInterface $items, mixed $description) : string|array {
  /** @var \Drupal\media\Plugin\media\Source\OEmbedInterface $source */
  $source = $items->getEntity()
    ->getSource();
  $message = $this->t('You can link to media from the following services: @providers', [
    '@providers' => implode(', ', $source->getProviders()),
  ]);
  if ($description) {
    return [
      '#theme' => 'item_list',
      '#items' => [
        $description,
        $message,
      ],
    ];
  }
  return $message;
}

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