Commit 05559060 authored by catch's avatar catch
Browse files

Issue #2587337 by sdstyles: hook_node_links_alter() names its parameters...

Issue #2587337 by sdstyles: hook_node_links_alter() names its parameters differently from its implementations
parent 33ba34e3
......@@ -88,7 +88,7 @@ function book_entity_type_build(array &$entity_types) {
/**
* Implements hook_node_links_alter().
*/
function book_node_links_alter(array &$node_links, NodeInterface $node, array &$context) {
function book_node_links_alter(array &$links, NodeInterface $node, array &$context) {
if ($context['view_mode'] != 'rss') {
$account = \Drupal::currentUser();
......@@ -97,14 +97,14 @@ function book_node_links_alter(array &$node_links, NodeInterface $node, array &$
$child_type = \Drupal::config('book.settings')->get('child_type');
$access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node');
if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_control_handler->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < BookManager::BOOK_MAX_DEPTH) {
$links['book_add_child'] = array(
$book_links['book_add_child'] = array(
'title' => t('Add child page'),
'url' => Url::fromRoute('node.add', ['node_type' => $child_type], ['query' => ['parent' => $node->id()]]),
);
}
if ($account->hasPermission('access printer-friendly version')) {
$links['book_printer'] = array(
$book_links['book_printer'] = array(
'title' => t('Printer-friendly version'),
'url' => Url::fromRoute('book.export', [
'type' => 'html',
......@@ -116,10 +116,10 @@ function book_node_links_alter(array &$node_links, NodeInterface $node, array &$
}
}
if (!empty($links)) {
$node_links['book'] = array(
if (!empty($book_links)) {
$links['book'] = array(
'#theme' => 'links__node__book',
'#links' => $links,
'#links' => $book_links,
'#attributes' => array('class' => array('links', 'inline')),
);
}
......
......@@ -194,15 +194,15 @@ function comment_field_config_delete(FieldConfigInterface $field) {
/**
* Implements hook_node_links_alter().
*/
function comment_node_links_alter(array &$node_links, NodeInterface $node, array &$context) {
function comment_node_links_alter(array &$links, NodeInterface $node, array &$context) {
// Comment links are only added to node entity type for backwards
// compatibility. Should you require comment links for other entity types you
// can do so by implementing a new field formatter.
// @todo Make this configurable from the formatter. See
// https://www.drupal.org/node/1901110.
$links = \Drupal::service('comment.link_builder')->buildCommentedEntityLinks($node, $context);
$node_links += $links;
$comment_links = \Drupal::service('comment.link_builder')->buildCommentedEntityLinks($node, $context);
$links += $comment_links;
}
/**
......
......@@ -48,20 +48,20 @@ function statistics_node_view(array &$build, EntityInterface $node, EntityViewDi
/**
* Implements hook_node_links_alter().
*/
function statistics_node_links_alter(array &$node_links, NodeInterface $entity, array &$context) {
function statistics_node_links_alter(array &$links, NodeInterface $entity, array &$context) {
if ($context['view_mode'] != 'rss') {
$node_links['#cache']['contexts'][] = 'user.permissions';
$links['#cache']['contexts'][] = 'user.permissions';
if (\Drupal::currentUser()->hasPermission('view post access counter')) {
$statistics = statistics_get($entity->id());
if ($statistics) {
$links['statistics_counter']['title'] = \Drupal::translation()->formatPlural($statistics['totalcount'], '1 view', '@count views');
$node_links['statistics'] = array(
$statistics_links['statistics_counter']['title'] = \Drupal::translation()->formatPlural($statistics['totalcount'], '1 view', '@count views');
$links['statistics'] = array(
'#theme' => 'links__node__statistics',
'#links' => $links,
'#links' => $statistics_links,
'#attributes' => array('class' => array('links', 'inline')),
);
}
$node_links['#cache']['max-age'] = \Drupal::config('statistics.settings')->get('display_max_age');
$links['#cache']['max-age'] = \Drupal::config('statistics.settings')->get('display_max_age');
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment