You are here

function _commerce_file_collate_license_info in Commerce File 7

Store information about license properties

14 calls to _commerce_file_collate_license_info()
commerce_file_feeds_processor_targets_alter in ./commerce_file.feeds.inc
Implements hook_feeds_processor_targets_alter().
commerce_file_field_info in includes/commerce_file.field.inc
Implements hook_field_info().
commerce_file_field_widget_info in includes/commerce_file.field.inc
Implements hook_field_widget_info().
commerce_file_license_form_after_build in includes/commerce_file_license.forms.inc
After build callback for commerce_file_license_form().
commerce_file_license_issue_by_commerce_line_item in includes/commerce_file.entities.inc
Issue licenses for files in a line item

... See full list

File

./commerce_file.module, line 327
Provides integration of file licenses with Commerce

Code

function _commerce_file_collate_license_info($reset = FALSE) {
  $info =& drupal_static(__FUNCTION__);
  if ($reset) {
    $info = NULL;
    cache_clear_all('commerce_file_license_info', 'cache');
    return;
  }

  // initialize cache
  if (!isset($info)) {
    if ($cached = cache_get('commerce_file_license_info', 'cache')) {

      // retrieve from stored cache
      $info = $cached->data;
    }
    else {

      // rebuild info and set stored cache
      $info = module_invoke_all('commerce_file_license_info');
      drupal_alter('commerce_file_license_info', $info);

      // set defaults
      foreach ($info as $k => &$data) {
        $data += array(
          'name' => $k,
          'title' => $k,
          'base_element' => array(
            '#type' => 'commerce_file_limit_integer',
            '#title' => $k,
          ),
          'callbacks' => array(),
        );
        $data['property info'] += array(
          'type' => 'integer',
          'label' => $data['title'],
          'description' => $data['title'],
          'getter callback' => 'entity_property_verbatim_get',
          'setter callback' => 'entity_property_verbatim_set',
          'validation callback' => '_commerce_file_metadata_validate_limit_integer_positive_or_zero',
          'queryable' => FALSE,
          // license custom property info
          'default_value' => COMMERCE_FILE_FIELD_UNLIMITED,
          'zero_value' => 0,
          'aggregated' => TRUE,
          'inheritable' => TRUE,
        );
      }
      unset($data);

      // store in cache
      cache_set('commerce_file_license_info', $info, 'cache');
    }
  }
  return $info;
}