Commit 12317b75 authored by webchick's avatar webchick

Issue #2283969 by tim.plunkett: Add a protected BlockBase::blockAccess() to...

Issue #2283969 by tim.plunkett: Add a protected BlockBase::blockAccess() to contain plugin-specific logic.
parent 5f6ca548
......@@ -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');
}
......
......@@ -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;
}
......
......@@ -32,7 +32,7 @@ public function defaultConfiguration() {
/**
* {@inheritdoc}
*/
public function access(AccountInterface $account) {
protected function blockAccess(AccountInterface $account) {
return $account->hasPermission('access content');
}
......
......@@ -56,7 +56,7 @@ public function defaultConfiguration() {
/**
* {@inheritdoc}
*/
public function access(AccountInterface $account) {
protected function blockAccess(AccountInterface $account) {
return $account->hasPermission('access content');
}
......
......@@ -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();
}
......
......@@ -33,7 +33,7 @@ public function defaultConfiguration() {
/**
* {@inheritdoc}
*/
public function access(AccountInterface $account) {
protected function blockAccess(AccountInterface $account) {
return $account->hasPermission('access content');
}
......
......@@ -26,7 +26,7 @@ class SearchBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function access(AccountInterface $account) {
protected function blockAccess(AccountInterface $account) {
return $account->hasPermission('search content');
}
......
......@@ -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:")))) {
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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')));
}
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment