1 |
fd5a8e62
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file flag_comment_flag_test.module
|
5 |
|
|
* Test module for comment flags.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Implements hook_comment_load().
|
10 |
|
|
*
|
11 |
|
|
* This is only called once when viewing a node with comments, and before
|
12 |
|
|
* hook_entity_view() is invoked. We use this to check the initial state of the
|
13 |
|
|
* cache.
|
14 |
|
|
*/
|
15 |
|
|
function flag_comment_flag_test_comment_load($comments) {
|
16 |
|
|
$flag_get_user_flags_cache = drupal_static('flag_get_user_flags');
|
17 |
|
|
|
18 |
|
|
// Store the value of the flag_get_user_flags() static cache in the variable,
|
19 |
|
|
// so the test can retrieve it.
|
20 |
|
|
$tracking_variable = variable_get('flag_comment_flag_test_user_flags_cache_tracking', array());
|
21 |
|
|
$tracking_variable['hook_comment_load'] = $flag_get_user_flags_cache;
|
22 |
|
|
variable_set('flag_comment_flag_test_user_flags_cache_tracking', $tracking_variable);
|
23 |
|
|
}
|
24 |
|
|
|
25 |
|
|
/**
|
26 |
|
|
* Implements hook_entity_view().
|
27 |
|
|
*
|
28 |
|
|
* Use hook_entity_view() rather than hook_comment_view() so we are in the same
|
29 |
|
|
* invocation as flag_entity_view().
|
30 |
|
|
*/
|
31 |
|
|
function flag_comment_flag_test_entity_view($entity, $type, $view_mode, $langcode) {
|
32 |
|
|
if ($type == 'comment') {
|
33 |
|
|
$flag_get_user_flags_cache = drupal_static('flag_get_user_flags');
|
34 |
|
|
|
35 |
|
|
// Store the value of the flag_get_user_flags() static cache in the variable,
|
36 |
|
|
// so the test can retrieve it.
|
37 |
|
|
$tracking_variable = variable_get('flag_comment_flag_test_user_flags_cache_tracking', array());
|
38 |
|
|
$tracking_variable['hook_entity_view_' . $entity->cid] = $flag_get_user_flags_cache;
|
39 |
|
|
variable_set('flag_comment_flag_test_user_flags_cache_tracking', $tracking_variable);
|
40 |
|
|
}
|
41 |
|
|
} |