Skip to content
Snippets Groups Projects
Commit f4e8b6df authored by Adrian Lorenc's avatar Adrian Lorenc
Browse files

ISAICP-9575: Add pseudo field: anonymous_comment_links

parent 5eec42e8
No related branches found
No related tags found
1 merge request!215Release 2.3.2
...@@ -44,6 +44,10 @@ function joinup_community_content_entity_extra_field_info(): array { ...@@ -44,6 +44,10 @@ function joinup_community_content_entity_extra_field_info(): array {
'description' => t('A link to share the content'), 'description' => t('A link to share the content'),
'visible' => FALSE, 'visible' => FALSE,
]; ];
$fields['node'][$bundle]['display']['anonymous_comment_links'] = [
'label' => t('Anonymous comment links'),
'visible' => FALSE,
];
} }
return $fields; return $fields;
...@@ -78,6 +82,16 @@ function joinup_community_content_node_view(array &$build, EntityInterface $enti ...@@ -78,6 +82,16 @@ function joinup_community_content_node_view(array &$build, EntityInterface $enti
], ],
]; ];
} }
if ($display->getComponent('anonymous_comment_links')) {
$current_user = \Drupal::currentUser();
$build['anonymous_comment_links']['#cache']['contexts'][] = 'user.roles:anonymous';
if ($current_user->isAnonymous()) {
$build['anonymous_comment_links']['content'] = [
'#theme' => 'anonymous_comment_links',
];
}
}
} }
/** /**
...@@ -202,6 +216,9 @@ function joinup_community_content_theme($existing, $type, $theme, $path): array ...@@ -202,6 +216,9 @@ function joinup_community_content_theme($existing, $type, $theme, $path): array
'url' => NULL, 'url' => NULL,
], ],
], ],
'anonymous_comment_links' => [
'variables' => [],
],
]; ];
} }
......
{#
/**
* @file
* Default theme implementation of anonymous comment links.
*
* @ingroup themeable
*/
#}
<p>
<a href="{{ path('cas.login') }}">Login</a> or
<a href="{{ path('user.register') }}">create an account</a> to comment.
</p>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment