protected function UserCreateUpdate::beforeUserSave in Apigee Edge 8
Execute actions before the user gets saved.
Parameters
\Drupal\apigee_edge\Structure\DeveloperToUserConversionResult $result: Result of the entity conversion.
Throws
\Exception Can throw an exception to abort user save.
2 calls to UserCreateUpdate::beforeUserSave()
- UserCreateUpdate::executeRequest in src/
Job/ UserCreateUpdate.php  - Executes the request itself.
 - UserUpdate::beforeUserSave in src/
Job/ UserUpdate.php  - Execute actions before the user gets saved.
 
1 method overrides UserCreateUpdate::beforeUserSave()
- UserUpdate::beforeUserSave in src/
Job/ UserUpdate.php  - Execute actions before the user gets saved.
 
File
- src/
Job/ UserCreateUpdate.php, line 108  
Class
- UserCreateUpdate
 - Base class for user create/update sync jobs.
 
Namespace
Drupal\apigee_edge\JobCode
protected function beforeUserSave(DeveloperToUserConversionResult $result) : void {
  // Abort the operation if any of these special problems occurred
  // meanwhile the conversation.
  foreach ($result
    ->getProblems() as $problem) {
    // Skip user save if username is already taken or the username
    // is too long instead of getting a database exception in a lower layer.
    // (Username field's value is not limited on Apigee Edge and it is not
    // unique either.)
    if ($problem instanceof DeveloperToUserConversationInvalidValueException && $problem
      ->getTarget() === 'name') {
      throw $problem;
    }
  }
  // It's necessary because changed time is automatically updated on the
  // UI only.
  $result
    ->getUser()
    ->setChangedTime(\Drupal::time()
    ->getCurrentTime());
}