You are here

function bynder_get_brands_list in Bynder 7

Retrieves Bynder brands list and sets it as values in the settings form.

1 string reference to 'bynder_get_brands_list'
bynder_batch_reload_derivatives in includes/bynder.admin.inc
Batch callback to fetch derivative information.

File

includes/bynder.admin.inc, line 162

Code

function bynder_get_brands_list(&$context) {
  try {
    $brandsList = BynderMediaApi::getBynderApi()
      ->getMediaBrands();
    if ($brandsList) {
      $options = array();
      foreach ($brandsList as $brand) {
        $options[$brand['id']] = $brand['name'];
      }
      variable_set('bynder_brands_list', $options);
      variable_set('bynder_brand_selected', array_keys($options)[0]);
    }
    else {
      $context['finished'] = 1;
    }
  } catch (Exception $e) {
    watchdog('bynder', $e
      ->getMessage());
    $context['finished'] = 1;
  }
}