class BlockUser

Blocks a user.

Plugin annotation


@Action(
  id = "user_block_user_action",
  label = @Translation("Block the selected users"),
  type = "user"
)

Hierarchy

Expanded class hierarchy of BlockUser

File

drupal/core/modules/user/lib/Drupal/user/Plugin/Action/BlockUser.php, line 23
Contains \Drupal\user\Plugin\Action\BlockUser.

Namespace

Drupal\user\Plugin\Action
View source
class BlockUser extends ActionBase {

  /**
   * {@inheritdoc}
   */
  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();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ActionBase::executeMultiple public function Executes the plugin for an array of objects. Overrides ActionInterface::executeMultiple 2
BlockUser::execute public function Executes the plugin. Overrides ExecutableInterface::execute
ContainerFactoryPluginBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create 11
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::getPluginDefinition public function Returns the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::__construct public function Constructs a Drupal\Component\Plugin\PluginBase object. 17