You are here

function piwik_stats_get_queue_items in Piwik Statistic Integration 7.2

Returns a dataset of fields to fill.

Return value

array An associative dataset array on success, empty array when failsave, FALSE otherwise.

3 calls to piwik_stats_get_queue_items()
drush_piwik_stats_fill in ./piwik_stats.drush.inc
Command Callback: Update piwik stats fields.
piwik_stats_cron in ./piwik_stats.module
Implements hook_cron().
piwik_stats_piwik_admin_settings_batch_submit in ./piwik_stats.module
Submit callback for filling piwik_stats fields manually by batch.

File

./piwik_stats.module, line 516
Integrates piwik statistics as entity fields.

Code

function piwik_stats_get_queue_items() {
  $queue = array();

  // Get all fields of type piwik_stats.
  $piwik_fields = field_read_fields(array(
    'type' => 'piwik_stats',
  ));

  // Iterate through all piwik fields.
  foreach ($piwik_fields as $field_name => $field) {

    // Get all instances of a piwik_stats field.
    $field_instances = field_read_instances(array(
      'field_id' => $field['id'],
    ));

    // Iterate through all instances of a piwik field.
    foreach ($field_instances as $field_instance) {

      // Get a list of all entity objects holding the needed id's.
      $entities = _piwik_stats_get_entities($field_instance['entity_type'], $field_instance['bundle']);

      // Iterate through entities and add all items to queue.
      foreach ($entities as $entity) {
        $queue[] = array(
          'entity' => $entity,
          'entity_type' => $field_instance['entity_type'],
          'field' => $field,
        );
      }
    }
  }
  return $queue;
}