You are here

function social_album_social_user_account_header_create_links in Open Social 10.2.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_album/social_album.module \social_album_social_user_account_header_create_links()
  2. 10.0.x modules/social_features/social_album/social_album.module \social_album_social_user_account_header_create_links()
  3. 10.1.x modules/social_features/social_album/social_album.module \social_album_social_user_account_header_create_links()

Implements hook_social_user_account_header_create_links().

Adds the "Create Album" link to the content creation menu.

File

modules/social_features/social_album/social_album.module, line 66
The Social Album module.

Code

function social_album_social_user_account_header_create_links($context) {

  // We require a user for this link with the permission to create albums.
  if (empty($context['user']) || !$context['user'] instanceof AccountInterface || !$context['user']
    ->hasPermission('create album content')) {
    return [];
  }

  // Lets add the new create album button to the + dropdown.
  return [
    'add_personal_album' => [
      '#type' => 'link',
      '#attributes' => [
        'title' => new TranslatableMarkup('Create New Album'),
      ],
      '#title' => new TranslatableMarkup('New Album'),
      '#weight' => 400,
    ] + Url::fromRoute('node.add', [
      'node_type' => 'album',
    ])
      ->toRenderArray(),
  ];
}