function FilterFormat::getFormatsAsOptions

Same name and namespace in other branches
  1. main core/modules/filter/src/Plugin/DataType/FilterFormat.php \Drupal\filter\Plugin\DataType\FilterFormat::getFormatsAsOptions()

Returns a list of filter format config entity labels keyed by their ID.

Parameters

\Drupal\Core\Session\AccountInterface|null $account: (optional) The user account for which to filter the options. If omitted, all options are returned.

Return value

array<string, \Drupal\filter\FilterFormatInterface> A list of filter format config entity labels keyed by their ID.

2 calls to FilterFormat::getFormatsAsOptions()
FilterFormat::getPossibleOptions in core/modules/filter/src/Plugin/DataType/FilterFormat.php
Returns an array of possible values with labels for display.
FilterFormat::getSettableOptions in core/modules/filter/src/Plugin/DataType/FilterFormat.php
Returns an array of settable values with labels for display.

File

core/modules/filter/src/Plugin/DataType/FilterFormat.php, line 60

Class

FilterFormat
The filter format data type.

Namespace

Drupal\filter\Plugin\DataType

Code

protected function getFormatsAsOptions(?AccountInterface $account = NULL) : array {
  $repository = \Drupal::service(FilterFormatRepositoryInterface::class);
  return array_map(fn(FilterFormatInterface $format): string|\Stringable => $format->label(), $account ? $repository->getFormatsForAccount($account) : $repository->getAllFormats());
}

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