You are here

public function BlockUser::execute in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Plugin/Action/BlockUser.php \Drupal\user\Plugin\Action\BlockUser::execute()

Executes the plugin.

Overrides ExecutableInterface::execute

File

core/modules/user/src/Plugin/Action/BlockUser.php, line 27
Contains \Drupal\user\Plugin\Action\BlockUser.

Class

BlockUser
Blocks a user.

Namespace

Drupal\user\Plugin\Action

Code

public function execute($account = NULL) {

  // Skip blocking user if they are already blocked.
  if ($account !== FALSE && $account
    ->isActive()) {

    // For efficiency manually save the original account before applying any
    // changes.
    $account->original = clone $account;
    $account
      ->block();
    $account
      ->save();
  }
}