You are here

public function FontAwesomeManager::getCategories in Font Awesome Icons 8.2

Get categories.

Return value

array List of all categories.

2 calls to FontAwesomeManager::getCategories()
FontAwesomeManager::getCategoriesByIcon in src/FontAwesomeManager.php
Get categories for a specific icon.
FontAwesomeManager::getIconsByCategory in src/FontAwesomeManager.php
Get icons for a specific category.

File

src/FontAwesomeManager.php, line 149

Class

FontAwesomeManager
Icon Manager Service for Font Awesome.

Namespace

Drupal\fontawesome

Code

public function getCategories() {

  // Check for cached categories.
  if (!($categories = $this->dataCache
    ->get('fontawesome.categorylist'))) {

    // Get the meatadata.
    $categories = $this
      ->getCategoryMetadata();

    // Cache the categories array.
    $this->dataCache
      ->set('fontawesome.categorylist', $categories, strtotime('+1 week'), [
      'fontawesome',
      'categorylist',
    ]);
  }
  else {
    $categories = $categories->data;
  }
  return (array) $categories;
}