function BlockPluginTrait::blockAccess

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Block/BlockPluginTrait.php \Drupal\Core\Block\BlockPluginTrait::blockAccess()
  2. 10 core/lib/Drupal/Core/Block/BlockPluginTrait.php \Drupal\Core\Block\BlockPluginTrait::blockAccess()
  3. 8.9.x core/lib/Drupal/Core/Block/BlockPluginTrait.php \Drupal\Core\Block\BlockPluginTrait::blockAccess()

Indicates whether the block should be shown.

Blocks with specific access checking should override this method rather than access(), in order to avoid repeating the handling of the $return_as_object argument.

Parameters

\Drupal\Core\Session\AccountInterface $account: The user session for which to check access.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

See also

self::access()

1 call to BlockPluginTrait::blockAccess()
BlockPluginTrait::access in core/lib/Drupal/Core/Block/BlockPluginTrait.php
4 methods override BlockPluginTrait::blockAccess()
ExtraFieldBlock::blockAccess in core/modules/layout_builder/src/Plugin/Block/ExtraFieldBlock.php
Indicates whether the block should be shown.
FieldBlock::blockAccess in core/modules/layout_builder/src/Plugin/Block/FieldBlock.php
Indicates whether the block should be shown.
InlineBlock::blockAccess in core/modules/layout_builder/src/Plugin/Block/InlineBlock.php
Indicates whether the block should be shown.
LanguageBlock::blockAccess in core/modules/language/src/Plugin/Block/LanguageBlock.php
Indicates whether the block should be shown.

File

core/lib/Drupal/Core/Block/BlockPluginTrait.php, line 146

Class

BlockPluginTrait
Provides the base implementation of a block plugin.

Namespace

Drupal\Core\Block

Code

protected function blockAccess(AccountInterface $account) {
  // By default, the block is visible.
  return AccessResult::allowed();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.