function FilterFormatRepository::getAllFormats

Same name and namespace in other branches
  1. 11.x core/modules/filter/src/FilterFormatRepository.php \Drupal\filter\FilterFormatRepository::getAllFormats()
2 calls to FilterFormatRepository::getAllFormats()
FilterFormatRepository::getFormatsByRole in core/modules/filter/src/FilterFormatRepository.php
FilterFormatRepository::getFormatsForAccount in core/modules/filter/src/FilterFormatRepository.php

File

core/modules/filter/src/FilterFormatRepository.php, line 46

Class

FilterFormatRepository
Provides a repository service for filter formats.

Namespace

Drupal\filter

Code

public function getAllFormats() : array {
  $langcode = $this->languageManager
    ->getCurrentLanguage()
    ->getId();
  $cid = "filter_formats:all:{$langcode}";
  if ($cached = $this->cache
    ->get($cid)) {
    return $cached->data;
  }
  $formats = $this->entityTypeManager
    ->getStorage('filter_format')
    ->loadByProperties([
    'status' => TRUE,
  ]);
  uasort($formats, ConfigEntityBase::class . '::sort');
  $this->cache
    ->set($cid, $formats, Cache::PERMANENT, $this->getCacheTags());
  return $formats;
}

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