W3cubDocs

/Drupal 8

protected function BlockBase::blockAccess

protected BlockBase::blockAccess(AccountInterface $account)

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\AccessResult The access result.

See also

self::access()

File

core/lib/Drupal/Core/Block/BlockBase.php, line 135

Class

BlockBase
Defines a base block implementation that most blocks plugins will extend.

Namespace

Drupal\Core\Block

Code

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

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Block!BlockBase.php/function/BlockBase::blockAccess/8.1.x