You are here

function hook_mostpopular_service_info in Drupal Most Popular 7

Defines one or more Most Popular services provided by this module.

Return value

array A keyed array of most popular service definitions, each of which can contain:

  • name: The name of the service, to display to admins.
  • title: The default title to display on the tab for this service. This can be overridden in the admin interface.
  • entity_types: If this is set, admins can choose which types of entities and bundles can be returned by this service. If set to TRUE, admins can choose from among all the entity types. If set to an array of entity types, admins can only choose from amongst the bundles of those types.
  • file: Optionally, the full path of a file to load before attempting to invoke callbacks.
  • callbacks: Optionally, an array of callback functions to use for this service. If a callback function is not specified in this array, the system will attempt to find one by prepending the module name to the callback name and if possible appending the key (delta) of this service. If no callback could be found and a default exists, the default will be used. In other words, callbacks are found in the following order:

    • $info['callbacks'][$callback]
    • $module_$callback_$delta
    • $module_$callback
    • mostpopular_default_$callback

    The available callbacks are:

    • refresh: Refreshes the most popular data for this service. This callback must exist and is where all the interesting things happen for this module.
    • config_form: Provides additional elements to the array for configuring a service.
    • next_run: Returns the timestamp of the next time the service should run. If not provided, a default will be used.
4 functions implement hook_mostpopular_service_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

mostpopular_addthis_mostpopular_service_info in modules/mostpopular_addthis/mostpopular_addthis.module
Implements hook_mostpopular_service_info().
mostpopular_disqus_mostpopular_service_info in modules/mostpopular_disqus/mostpopular_disqus.module
Implements hook_mostpopular_service_info().
mostpopular_drupal_mostpopular_service_info in modules/mostpopular_drupal/mostpopular_drupal.module
Implements hook_mostpopular_service_info().
mostpopular_ga_mostpopular_service_info in modules/mostpopular_ga/mostpopular_ga.module
Implements hook_mostpopular_service_info().
1 invocation of hook_mostpopular_service_info()
mostpopular_service_info in ./mostpopular.module
Gets the list of available services.

File

./mostpopular.api.inc, line 47
Provides examples of the hooks and callbacks that can be implemented to add new services to the Most Popular framework.

Code

function hook_mostpopular_service_info() {
  $info = array();
  $info['viewed'] = array(
    'name' => t('Drupal Most Viewed Nodes'),
    'title' => t('Viewed'),
    'entity_types' => array(
      'node',
    ),
    // This service can only return nodes.
    'callbacks' => array(
      'refresh_viewed' => 'callback_mostpopular_refresh_viewed',
      'next_run' => 'callback_mostpopular_next_run',
    ),
  );
  $info['commented'] = array(
    'name' => t('Drupal Most Commented Nodes'),
    'title' => t('Commented'),
    'entity_types' => TRUE,
  );
  return $info;
}