public function SocialEventInviteLocalActionsBlock::build in Open Social 8.9
Same name and namespace in other branches
- 10.3.x modules/social_features/social_event/modules/social_event_invite/src/Plugin/Block/SocialEventInviteLocalActionsBlock.php \Drupal\social_event_invite\Plugin\Block\SocialEventInviteLocalActionsBlock::build()
- 10.0.x modules/social_features/social_event/modules/social_event_invite/src/Plugin/Block/SocialEventInviteLocalActionsBlock.php \Drupal\social_event_invite\Plugin\Block\SocialEventInviteLocalActionsBlock::build()
- 10.1.x modules/social_features/social_event/modules/social_event_invite/src/Plugin/Block/SocialEventInviteLocalActionsBlock.php \Drupal\social_event_invite\Plugin\Block\SocialEventInviteLocalActionsBlock::build()
- 10.2.x modules/social_features/social_event/modules/social_event_invite/src/Plugin/Block/SocialEventInviteLocalActionsBlock.php \Drupal\social_event_invite\Plugin\Block\SocialEventInviteLocalActionsBlock::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
- modules/
social_features/ social_event/ modules/ social_event_invite/ src/ Plugin/ Block/ SocialEventInviteLocalActionsBlock.php, line 95
Class
- SocialEventInviteLocalActionsBlock
- Provides a 'SocialEventInviteLocalActionsBlock' block.
Namespace
Drupal\social_event_invite\Plugin\BlockCode
public function build() {
$build = [];
// Get current node so we can build correct links.
$event = $this
->getContextValue('node');
if ($event instanceof NodeInterface) {
$links = [
'#type' => 'dropbutton',
'#attributes' => [
'class' => [
'add-users-dropbutton',
],
'no-split' => [
'title' => $this
->t('Add enrollees'),
'alignment' => 'right',
],
],
'#links' => [
'add_directly' => [
'title' => $this
->t('Add directly'),
'url' => Url::fromRoute('social_event_managers.add_enrollees', [
'node' => $event
->id(),
]),
],
'invite_by_mail' => [
'title' => $this
->t('Invite users'),
'url' => Url::fromRoute('social_event_invite.invite_email', [
'node' => $event
->id(),
]),
],
'view_invites' => [
'title' => $this
->t('View invites'),
'url' => Url::fromRoute('view.event_manage_enrollment_invites.page_manage_enrollment_invites', [
'node' => $event
->id(),
]),
],
],
];
$build['content'] = $links;
$build['#cache'] = [
'keys' => [
'social_event_invite_block',
'node',
$event
->id(),
],
'contexts' => [
'user',
],
];
}
return $build;
}