diff --git a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php index 5fdc33a..4381b6d 100644 --- a/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php +++ b/core/modules/aggregator/src/Plugin/Block/AggregatorFeedBlock.php @@ -100,7 +100,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { // Only grant access to users with the 'access news feeds' permission. return $account->hasPermission('access news feeds'); } diff --git a/core/modules/block/src/BlockBase.php b/core/modules/block/src/BlockBase.php index 56b1662..994b12e 100644 --- a/core/modules/block/src/BlockBase.php +++ b/core/modules/block/src/BlockBase.php @@ -112,8 +112,23 @@ public function calculateDependencies() { * {@inheritdoc} */ public function access(AccountInterface $account) { - // By default, the block is visible unless user-configured rules indicate - // that it should be hidden. + // @todo Move block visibility here in https://drupal.org/node/2278541. + return $this->blockAccess($account); + } + + /** + * Indicates whether the block should be shown. + * + * @param \Drupal\Core\Session\AccountInterface $account + * The user session for which to check access. + * + * @return bool + * TRUE if the block should be shown, or FALSE otherwise. + * + * @see self::access() + */ + protected function blockAccess(AccountInterface $account) { + // By default, the block is visible. return TRUE; } diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php index 85856a3..9a4db70 100644 --- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php +++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestBlockInstantiation.php @@ -32,7 +32,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { return $account->hasPermission('access content'); } diff --git a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php index d7dfc31..6a5b492 100644 --- a/core/modules/forum/src/Plugin/Block/ForumBlockBase.php +++ b/core/modules/forum/src/Plugin/Block/ForumBlockBase.php @@ -56,7 +56,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { return $account->hasPermission('access content'); } diff --git a/core/modules/language/src/Plugin/Block/LanguageBlock.php b/core/modules/language/src/Plugin/Block/LanguageBlock.php index 4a6c7bc..42d5bf3 100644 --- a/core/modules/language/src/Plugin/Block/LanguageBlock.php +++ b/core/modules/language/src/Plugin/Block/LanguageBlock.php @@ -66,7 +66,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { return $this->languageManager->isMultilingual(); } diff --git a/core/modules/node/src/Plugin/Block/SyndicateBlock.php b/core/modules/node/src/Plugin/Block/SyndicateBlock.php index efc1bdf..ace314a 100644 --- a/core/modules/node/src/Plugin/Block/SyndicateBlock.php +++ b/core/modules/node/src/Plugin/Block/SyndicateBlock.php @@ -33,7 +33,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { return $account->hasPermission('access content'); } diff --git a/core/modules/search/src/Plugin/Block/SearchBlock.php b/core/modules/search/src/Plugin/Block/SearchBlock.php index c2e3e51..64b3096 100644 --- a/core/modules/search/src/Plugin/Block/SearchBlock.php +++ b/core/modules/search/src/Plugin/Block/SearchBlock.php @@ -26,7 +26,7 @@ class SearchBlock extends BlockBase { /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { return $account->hasPermission('search content'); } diff --git a/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php b/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php index 1a19761..3bdacac 100644 --- a/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php +++ b/core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php @@ -55,7 +55,7 @@ public function defaultConfiguration() { /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { if ($account->hasPermission('access content')) { $daytop = $this->configuration['top_day_num']; if (!$daytop || !($result = statistics_title_list('daycount', $daytop)) || !($this->day_list = node_title_list($result, t("Today's:")))) { diff --git a/core/modules/system/src/Plugin/Block/SystemHelpBlock.php b/core/modules/system/src/Plugin/Block/SystemHelpBlock.php index d15cfc6..e99787c 100644 --- a/core/modules/system/src/Plugin/Block/SystemHelpBlock.php +++ b/core/modules/system/src/Plugin/Block/SystemHelpBlock.php @@ -78,7 +78,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { $this->help = $this->getActiveHelp($this->request); return (bool) $this->help; } diff --git a/core/modules/system/tests/modules/form_test/src/Plugin/Block/RedirectFormBlock.php b/core/modules/system/tests/modules/form_test/src/Plugin/Block/RedirectFormBlock.php index 9703f4c..21b79b3 100644 --- a/core/modules/system/tests/modules/form_test/src/Plugin/Block/RedirectFormBlock.php +++ b/core/modules/system/tests/modules/form_test/src/Plugin/Block/RedirectFormBlock.php @@ -66,7 +66,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { return TRUE; } diff --git a/core/modules/user/src/Plugin/Block/UserLoginBlock.php b/core/modules/user/src/Plugin/Block/UserLoginBlock.php index 01e1ebd..2cd54f4 100644 --- a/core/modules/user/src/Plugin/Block/UserLoginBlock.php +++ b/core/modules/user/src/Plugin/Block/UserLoginBlock.php @@ -25,7 +25,7 @@ class UserLoginBlock extends BlockBase { /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { $route_name = \Drupal::request()->attributes->get(RouteObjectInterface::ROUTE_NAME); return ($account->isAnonymous() && !in_array($route_name, array('user.register', 'user.login', 'user.logout'))); } diff --git a/core/modules/views/src/Plugin/Block/ViewsBlockBase.php b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php index b0bfdba..5a63e76 100644 --- a/core/modules/views/src/Plugin/Block/ViewsBlockBase.php +++ b/core/modules/views/src/Plugin/Block/ViewsBlockBase.php @@ -91,7 +91,7 @@ public static function create(ContainerInterface $container, array $configuratio /** * {@inheritdoc} */ - public function access(AccountInterface $account) { + protected function blockAccess(AccountInterface $account) { return $this->view->access($this->displayID); }