Add our first context condition
[sandbox/ianmthomasuk/1842676.git] / apachesolr_context_conditions.module
1 <?php
2
3 /**
4 * Implements hook_context_plugins.
5 */
6 function apachesolr_context_conditions_context_plugins() {
7 $plugins = array();
8 $plugins['apachesolr_context_conditions_context_condition_max_results'] = array(
9 'handler' => array(
10 'path' => drupal_get_path('module', 'apachesolr_context_conditions') .'/plugins',
11 'file' => 'apachesolr_context_conditions_context_condition_max_results.inc',
12 'class' => 'apachesolr_context_conditions_context_condition_max_results',
13 'parent' => 'context_condition',
14 ),
15 );
16 return $plugins;
17 }
18
19 /**
20 * Implements hook_context_registry.
21 */
22 function apachesolr_context_conditions_context_registry() {
23 return array(
24 'conditions' => array(
25 'apachesolr_max_results' => array(
26 'title' => t('Apache Solr - Max results'),
27 'plugin' => 'apachesolr_context_conditions_context_condition_max_results',
28 ),
29 ),
30 );
31 }
32
33 /**
34 * Implements hook_apachesolr_process_results
35 */
36 function apachesolr_context_conditions_apachesolr_process_results($results, $query) {
37 if ($plugin = context_get_plugin('condition', 'apachesolr_max_results')) {
38 $plugin->execute(count($results));
39 }
40 }