You are here

public function BlockPermissionsAccessControlHandler::blockAddFormAccess in Block permissions 8

Access check for the add block form.

Parameters

string $plugin_id: The plugin name.

string $theme: The theme name.

Return value

\Drupal\Core\Access\AccessResult An access result.

File

src/BlockPermissionsAccessControlHandler.php, line 109

Class

BlockPermissionsAccessControlHandler
Controller for the block permissions.

Namespace

Drupal\block_permissions

Code

public function blockAddFormAccess($plugin_id, $theme) {
  $plugin = $this->blockManager
    ->getDefinition($plugin_id);

  // Check if the user has the proper permissions.
  $access = AccessResult::allowedIfHasPermissions($this->currentUser, [
    'administer blocks provided by ' . $plugin['provider'],
    'administer block settings for theme ' . $theme,
  ]);
  return $access;
}