public function BlockUser::execute

Executes the plugin.

Overrides ExecutableInterface::execute

File

drupal/core/modules/user/lib/Drupal/user/Plugin/Action/BlockUser.php, line 28
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->status->value == 1) {

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