public function PrivateMessageActionsBlock::build in Private Message 8
Same name and namespace in other branches
- 8.2 src/Plugin/Block/PrivateMessageActionsBlock.php \Drupal\private_message\Plugin\Block\PrivateMessageActionsBlock::build()
Builds and returns the renderable array for this block plugin.
If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).
Return value
array A renderable array representing the content of the block.
Overrides BlockPluginInterface::build
See also
\Drupal\block\BlockViewBuilder
File
- src/
Plugin/ Block/ PrivateMessageActionsBlock.php, line 83
Class
- PrivateMessageActionsBlock
- Provides the private message actions block.
Namespace
Drupal\private_message\Plugin\BlockCode
public function build() {
if ($this->currentUser
->hasPermission('use private messaging system') && $this->currentRouteMatcher
->getRouteName() == 'private_message.private_message_page') {
$url = Url::fromRoute('private_message.private_message_create');
$block['links'] = [
'#type' => 'link',
'#title' => $this
->t('Create Private Message'),
'#url' => $url,
];
// Add the default classes, as these are not added when the block output
// is overridden with a template.
$block['#attributes']['class'][] = 'block';
$block['#attributes']['class'][] = 'block-private-message';
$block['#attributes']['class'][] = 'block-private-message-actions-block';
return $block;
}
}