UnblockUser.php in Drupal 9
File
core/modules/user/src/Plugin/Action/UnblockUser.php
View source
<?php
namespace Drupal\user\Plugin\Action;
use Drupal\Core\Action\ActionBase;
use Drupal\Core\Session\AccountInterface;
class UnblockUser extends ActionBase {
public function execute($account = NULL) {
if ($account !== FALSE && $account
->isBlocked()) {
$account
->activate();
$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();
}
}