You are here

public function UserDashboardSectionStorage::access in Dashboards with Layout Builder 2.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/SectionStorage/UserDashboardSectionStorage.php \Drupal\dashboards\Plugin\SectionStorage\UserDashboardSectionStorage::access()

Overrides \Drupal\Core\Access\AccessibleInterface::access().

Overrides DashboardSectionStorage::access

File

src/Plugin/SectionStorage/UserDashboardSectionStorage.php, line 103

Class

UserDashboardSectionStorage
Class DashboardSectionStorage.

Namespace

Drupal\dashboards\Plugin\SectionStorage

Code

public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) {
  if (!$account) {
    $account = $this->account;
  }
  $result = AccessResult::allowedIfHasPermission($account, 'administer dashboards')
    ->orIf(AccessResult::allowedIfHasPermission($account, 'can override ' . $this
    ->getDashboard()
    ->id() . ' dashboard'));
  if ($return_as_object) {
    return $result;
  }
  return $result
    ->isAllowed();
}