public function FontAwesomeManager::getIconsWithCategories in Font Awesome Icons 8.2
Get icons with category data included.
Return value
array List of all icons.
File
- src/FontAwesomeManager.php, line 120 
Class
- FontAwesomeManager
- Icon Manager Service for Font Awesome.
Namespace
Drupal\fontawesomeCode
public function getIconsWithCategories() {
  // Check for cached icons.
  if (!($icons = $this->dataCache
    ->get('fontawesome.iconcategorylist'))) {
    $icons = $this
      ->getIcons();
    // Loop over the icons and add categories to each.
    foreach ($icons as &$icon) {
      // Get the categories for this icon.
      $icon['categories'] = $this
        ->getCategoriesByIcon($icon['name']);
      // Merge the categories into the search terms.
      $icon['search_terms'] = array_values(array_unique($icon['search_terms'] + array_flip($icon['categories'])));
    }
    // Cache the icons array.
    $this->dataCache
      ->set('fontawesome.iconcategorylist', $icons, strtotime('+1 week'), [
      'fontawesome',
      'iconcategorylist',
    ]);
  }
  else {
    $icons = $icons->data;
  }
  return $icons;
}