public function WeatherUserDisplayBlock::blockAccess in Weather 2.0.x
Same name and namespace in other branches
- 8 src/Plugin/Block/WeatherUserDisplayBlock.php \Drupal\weather\Plugin\Block\WeatherUserDisplayBlock::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\AccessResult The access result.
Overrides BlockPluginTrait::blockAccess
See also
File
- src/
Plugin/ Block/ WeatherUserDisplayBlock.php, line 75
Class
- WeatherUserDisplayBlock
- Provides a 'WeatherUserDisplayBlock' block plugin.
Namespace
Drupal\weather\Plugin\BlockCode
public function blockAccess(AccountInterface $account, $return_as_object = FALSE) {
// Allow access if user has permission and has configured
// own weather display already.
return AccessResult::allowedIf($this->currentUser
->hasPermission('administer custom weather block') && $this->weatherDisplay instanceof WeatherDisplayInterface);
}