You are here

public function CommerceGuysMarketplaceAddonManager::getCategories in Commerce Guys Marketplace 7

Returns an array of all defined addon categories, used for filtering.

Parameters

$reset: Boolean indicating whether or not the cache should be reset, causing data to be refetched from the remote service.

Return value

An array of categories in the form of $id => $name.

File

includes/commerceguys_marketplace.addon.inc, line 79

Class

CommerceGuysMarketplaceAddonManager
Defines the manager class for interacting with remote marketplace addons.

Code

public function getCategories($reset = FALSE) {
  if (!$reset && ($cached_data = cache_get('marketplace_addon_categories'))) {
    $categories = $cached_data->data;
  }
  else {
    $response = drupal_http_request($this->endpoint . '/addon_categories');
    $categories = json_decode($response->data);
    cache_set('marketplace_addon_categories', $categories, CACHE_TEMPORARY);
  }
  return $categories;
}