function photos_node_links_alter in Album Photos 8.4
Implements hook_node_links_alter().
File
- ./
photos.module, line 769 - Implementation of photos.module.
Code
function photos_node_links_alter(array &$links, NodeInterface $node, array &$context) {
// Add node link(s).
$node_type = $node
->getType();
if ($node_type == 'photos') {
// Links.
$node_links = [];
if (\Drupal::currentUser()
->hasPermission('view photo') && isset($node->album['count'])) {
$title = t('Album view');
$type = 'album';
$count = 0;
if (!empty($node->album['count'])) {
$count = $node->album['count'];
}
if ($count != 0) {
$node_links['photos_album'] = [
'title' => $title,
'url' => Url::fromUri('base:photos/' . $type . '/' . $node
->id()),
'attributes' => [
'title' => t('A total of @count images', [
'@count' => $count,
]),
],
];
}
}
$links['photos'] = [
'#theme' => 'links__node__photos',
'#attributes' => [
'class' => [
'links',
'inline',
],
],
'#links' => $node_links,
];
}
}