BlockUser.php in Drupal 9
File
core/modules/user/src/Plugin/Action/BlockUser.php
View source
<?php
namespace Drupal\user\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
class BlockUser extends ActionBase {
public function execute($account = NULL) {
if ($account !== FALSE && $account
->isActive()) {
$account->original = clone $account;
$account
->block();
$account
->save();
}
}
public function access($object, AccountInterface $account = NULL, $return_as_object = FALSE) {
$access = $object->status
->access('edit', $account, TRUE)
->andIf($object
->access('update', $account, TRUE));
return $return_as_object ? $access : $access
->isAllowed();
}
}