You are here

public function SocialBlockUser::execute in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  2. 8.2 modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  3. 8.3 modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  4. 8.4 modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  5. 8.5 modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  6. 8.6 modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  7. 8.7 modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  8. 8.8 modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  9. 10.3.x modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  10. 10.0.x modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  11. 10.1.x modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()
  12. 10.2.x modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php \Drupal\social_user\Plugin\Action\SocialBlockUser::execute()

Executes the plugin.

Overrides ExecutableInterface::execute

File

modules/social_features/social_user/src/Plugin/Action/SocialBlockUser.php, line 21

Class

SocialBlockUser
Alternate action plugin that can block users.

Namespace

Drupal\social_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();
  }
}