You are here

function blog_node_links_alter in Blog 3.x

Same name and namespace in other branches
  1. 8.2 blog.module \blog_node_links_alter()

Implements hook_node_links_alter().

File

./blog.module, line 70
Enables multi-user blogs.

Code

function blog_node_links_alter(array &$node_links, NodeInterface $entity, array &$context) {
  if ($entity
    ->getEntityTypeId() == 'node' && $entity
    ->bundle() == 'blog_post' && $context['view_mode'] != 'rss') {
    $links['blog_usernames_blog'] = [
      'title' => t("@username's Blog", [
        '@username' => $entity
          ->getOwner()
          ->getDisplayName(),
      ]),
      'url' => Url::fromRoute('view.blog.blog_user_all', [
        'arg_0' => $entity
          ->getOwnerId(),
      ]),
      'attributes' => [
        'title' => t("Read @username's latest blog entries.", [
          '@username' => $entity
            ->getOwner()
            ->getDisplayName(),
        ]),
      ],
    ];
    $node_links['usernames_blog'] = [
      '#theme' => 'links__node__blog',
      '#links' => $links,
      '#attributes' => [
        'class' => [
          'links',
          'inline',
        ],
      ],
    ];
  }
}