function piwik_stats_process_queue_item in Piwik Statistic Integration 7.2
Processes a dataset for filling a field.
Parameters
array $item: An associative array containing:
- 'entity': The entity having a piwik field to update.
- 'entity_type': Machine readable type of the entity.
- 'field': Array of the field config.
1 call to piwik_stats_process_queue_item()
- drush_piwik_stats_fill in ./
piwik_stats.drush.inc - Command Callback: Update piwik stats fields.
2 string references to 'piwik_stats_process_queue_item'
- piwik_stats_cron_queue_info in ./
piwik_stats.module - Implements hook_cron_queue_info().
- 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 561 - Integrates piwik statistics as entity fields.
Code
function piwik_stats_process_queue_item($item) {
// Request the statistical data (API request / cache).
$xml = piwik_stats_get_xml_data($item['field']);
if (!empty($xml)) {
// Get the default URI of the current entity.
$entity_uri = entity_uri($item['entity_type'], $item['entity']);
// Get all URL aliases linked to the entity URI.
$urls = _piwik_stats_get_aliases($entity_uri['path']);
// Sum up all statistical data of each URL to a piwik field.
$piwik_stats_field = _piwik_stats_summarize_field($urls, $xml);
// Add the filled piwik stats field to the entity.
$item['entity']->{$item['field']['field_name']} = $piwik_stats_field;
// Save the updated piwik field (without touching the node or any other fields).
_piwik_stats_field_update($item['entity_type'], $item['entity'], $item['field']);
}
}