PmAddBlock.php in Open Social 8.4
Same filename and directory in other branches
- 8.9 modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 8 modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 8.2 modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 8.3 modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 8.5 modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 8.6 modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 8.7 modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 8.8 modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 10.3.x modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 10.0.x modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 10.1.x modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
- 10.2.x modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.php
File
modules/social_features/social_private_message/src/Plugin/Block/PmAddBlock.phpView source
<?php
namespace Drupal\social_private_message\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Url;
use Drupal\Core\Link;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Provides a 'PmAddBlock' block.
*
* @Block(
* id = "pm_add_block",
* admin_label = @Translation("Private Message add block"),
* )
*/
class PmAddBlock extends BlockBase {
/**
* {@inheritdoc}
*
* Custom access logic to display the block.
*/
public function blockAccess(AccountInterface $account) {
return AccessResult::allowed();
}
/**
* {@inheritdoc}
*/
public function build() {
$build = [];
$url = Url::fromRoute('private_message.private_message_create');
$link_options = [
'attributes' => [
'class' => [
'btn',
'btn-primary',
'btn-raised',
'brand-bg-primary',
],
],
];
$url
->setOptions($link_options);
$build['content'] = Link::fromTextAndUrl(t('New message'), $url)
->toRenderable();
return $build;
}
}
Classes
Name | Description |
---|---|
PmAddBlock | Provides a 'PmAddBlock' block. |