You are here

function entity_metadata_statistics_node_get_properties in Entity API 7

Callback for getting statistics properties.

See also

entity_metadata_statistics_entity_info_alter()

1 string reference to 'entity_metadata_statistics_node_get_properties'
entity_metadata_statistics_entity_property_info_alter in modules/statistics.info.inc
Implements hook_entity_property_info_alter() on top of statistics module.

File

modules/callbacks.inc, line 205
Provides various callbacks for the whole core module integration.

Code

function entity_metadata_statistics_node_get_properties($node, array $options, $name) {
  $statistics = (array) statistics_get($node->nid);
  $statistics += array(
    'totalcount' => 0,
    'daycount' => 0,
    'timestamp' => NULL,
  );
  switch ($name) {
    case 'views':
      return $statistics['totalcount'];
    case 'day_views':
      return $statistics['daycount'];
    case 'last_view':
      return $statistics['timestamp'];
  }
}