You are here

function apigee_edge_user_cancel in Apigee Edge 8

Implements hook_user_cancel().

File

./apigee_edge.module, line 1394
Copyright 2018 Google Inc.

Code

function apigee_edge_user_cancel(array $edit, UserInterface $account, $method) {
  if ($method === 'user_cancel_block_unpublish' || $method === 'user_cancel_block') {

    /** @var \Drupal\apigee_edge\UserDeveloperConverterInterface $user_developer */
    $user_developer = \Drupal::service('apigee_edge.converter.user_developer');

    /** @var \Drupal\Core\Logger\LoggerChannelInterface $logger */
    $logger = \Drupal::service('logger.channel.apigee_edge');
    try {

      /** @var \Drupal\apigee_edge\Entity\Developer $developer */
      $developer = $user_developer
        ->convertUser($account)
        ->getDeveloper();
      $developer
        ->save();
    } catch (\Exception $exception) {
      $context = [
        '@developer' => $account
          ->getEmail(),
        '@message' => (string) $exception,
      ];
      $context += Error::decodeException($exception);
      $logger
        ->error('Could not block @developer developer. @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
    }
  }
}