isActive()) { // For efficiency manually save the original account before applying any // changes. $account->setOriginal(clone $account); $account->block(); $account->save(); } } /** * {@inheritdoc} */ public function access($object, ?AccountInterface $account = NULL, $return_as_object = FALSE) { /** @var \Drupal\user\UserInterface $object */ $access = $object->status->access('edit', $account, TRUE) ->andIf($object->access('update', $account, TRUE)); return $return_as_object ? $access : $access->isAllowed(); } }