public function PrivateMessageActionsBlock::build in Private Message 8.2
Same name and namespace in other branches
- 8 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')) {
$config = $config = $this->configFactory
->get('private_message.settings');
$url = Url::fromRoute('private_message.private_message_create');
$block['links'] = [
'#type' => 'link',
'#title' => $config
->get("create_message_label"),
'#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;
}
}