summaryrefslogtreecommitdiff
path: root/modules/comment
diff options
context:
space:
mode:
authorDavid Rothstein <drothstein@gmail.com>2014-11-01 17:31:26 -0400
committerDavid Rothstein <drothstein@gmail.com>2014-11-01 17:31:26 -0400
commitc312e5ee5589d060601f633deba3be26df494815 (patch)
tree0db9e745cdbefcec1cb9d6453669139901bf9546 /modules/comment
parent5aede0dadeb785ca30f5e16c6d67281286a047ee (diff)
downloadbrdo-c312e5ee5589d060601f633deba3be26df494815.tar.gz
brdo-c312e5ee5589d060601f633deba3be26df494815.tar.bz2
Issue #1968348 by znerol, David_Rothstein, peximo, DuaelFr: Fixed hook_field_formatter_prepare_view does not make use of hook_entity_view_mode_alter causing major errors.
Diffstat (limited to 'modules/comment')
-rw-r--r--modules/comment/comment.module28
1 files changed, 16 insertions, 12 deletions
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 3c942002c..2972474c0 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -993,12 +993,7 @@ function comment_build_content($comment, $node, $view_mode = 'full', $langcode =
$comment->content = array();
// Allow modules to change the view mode.
- $context = array(
- 'entity_type' => 'comment',
- 'entity' => $comment,
- 'langcode' => $langcode,
- );
- drupal_alter('entity_view_mode', $view_mode, $context);
+ $view_mode = key(entity_view_mode_prepare('comment', array($comment->cid => $comment), $view_mode, $langcode));
// Build fields content.
field_attach_prepare_view('comment', array($comment->cid => $comment), $view_mode, $langcode);
@@ -1108,17 +1103,26 @@ function comment_links($comment, $node) {
* An array in the format expected by drupal_render().
*/
function comment_view_multiple($comments, $node, $view_mode = 'full', $weight = 0, $langcode = NULL) {
- field_attach_prepare_view('comment', $comments, $view_mode, $langcode);
- entity_prepare_view('comment', $comments, $langcode);
+ $build = array();
+ $entities_by_view_mode = entity_view_mode_prepare('comment', $comments, $view_mode, $langcode);
+ foreach ($entities_by_view_mode as $entity_view_mode => $entities) {
+ field_attach_prepare_view('comment', $entities, $entity_view_mode, $langcode);
+ entity_prepare_view('comment', $entities, $langcode);
+
+ foreach ($entities as $entity) {
+ $build[$entity->cid] = comment_view($entity, $node, $entity_view_mode, $langcode);
+ }
+ }
- $build = array(
- '#sorted' => TRUE,
- );
foreach ($comments as $comment) {
- $build[$comment->cid] = comment_view($comment, $node, $view_mode, $langcode);
$build[$comment->cid]['#weight'] = $weight;
$weight++;
}
+ // Sort here, to preserve the input order of the entities that were passed to
+ // this function.
+ uasort($build, 'element_sort');
+ $build['#sorted'] = TRUE;
+
return $build;
}