You are here

function blog_user_view in Blog 8.2

Same name and namespace in other branches
  1. 3.x blog.module \blog_user_view()

Implements hook_ENTITY_TYPE_view().

File

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

Code

function blog_user_view(&$build, $account, $display, $view_mode) {
  if ($account
    ->hasPermission('create blog_post content')) {

    // Build internal link based on router.
    $url = Url::fromRoute('view.blog.blog_user_all', [
      'arg_0' => $account
        ->id(),
    ]);
    $internal_link = Link::fromTextAndUrl(t('View recent blog entries'), $url)
      ->toString();
    $build['blog__personal_blog_link'] = [
      '#type' => 'item',
      '#title' => t('Blog'),
      '#title_display' => 'invisible',
      '#markup' => $internal_link,
      '#attributes' => [
        'class' => [
          'blog',
        ],
      ],
    ];
  }
}