class UserUpdate in Apigee Edge 8
A job to update a Drupal user based on an Apigee Edge developer.
Hierarchy
- class \Drupal\apigee_edge\Job\Job
- class \Drupal\apigee_edge\Job\EdgeJob
- class \Drupal\apigee_edge\Job\UserCreateUpdate uses UserDeveloperSyncJobTrait
- class \Drupal\apigee_edge\Job\UserUpdate
- class \Drupal\apigee_edge\Job\UserCreateUpdate uses UserDeveloperSyncJobTrait
- class \Drupal\apigee_edge\Job\EdgeJob
Expanded class hierarchy of UserUpdate
File
- src/
Job/ UserUpdate.php, line 28
Namespace
Drupal\apigee_edge\JobView source
class UserUpdate extends UserCreateUpdate {
/**
* {@inheritdoc}
*/
protected function beforeUserSave(DeveloperToUserConversionResult $result) : void {
parent::beforeUserSave($result);
/** @var \Drupal\user\UserInterface $original_user */
$original_user = \Drupal::entityTypeManager()
->getStorage('user')
->loadUnchanged($result
->getUser()
->id());
// Even if the developer has been blocked in Apigee Edge we should not block
// its Drupal user automatically when syncing.
if ($original_user
->isActive() && $result
->getUser()
->isBlocked()) {
$result
->getUser()
->activate();
}
$context = [
'link' => $result
->getUser()
->toLink(t('View user'))
->toString(),
];
$this
->logConversionProblems($result
->getProblems(), $context);
// Rollback a synchronised field's value if the related attribute's value
// contained an incorrect field value.
if (count($result
->getProblems()) > 0) {
/** @var \Drupal\user\UserInterface $original_user */
foreach ($result
->getProblems() as $problem) {
// Do not apply rollback on base fields.
if ($problem instanceof DeveloperToUserConversationInvalidValueException && !in_array($problem
->getTarget(), $this
->userDeveloperConverter()::DEVELOPER_PROP_USER_BASE_FIELD_MAP, TRUE)) {
$result
->getUser()
->set($problem
->getTarget(), $original_user
->get($problem
->getTarget())
->getValue());
}
}
}
}
/**
* {@inheritdoc}
*/
public function __toString() : string {
return t('Updating user (@email) from Apigee Edge.', [
'@email' => $this->email,
])
->render();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EdgeJob:: |
protected | property | Request data. | |
EdgeJob:: |
protected | property | Response data. | |
EdgeJob:: |
public | function |
Executes this job. Overrides Job:: |
1 |
EdgeJob:: |
protected | function | Returns the SDK connector instance from the global container. | |
EdgeJob:: |
public | function |
Returns this job's visual representation. Overrides Job:: |
|
Job:: |
protected | property | Exception storage. | |
Job:: |
private | property | Job ID. | |
Job:: |
protected | property | Messages storage. | |
Job:: |
protected | property | Remaining retries. | |
Job:: |
protected | property | Job status. | |
Job:: |
private | property | The tag of the job. | |
Job:: |
protected | constant | Job statuses. | |
Job:: |
public | function | Consumes a retry. | |
Job:: |
public | constant | Job is failed, and it won't be retried. | |
Job:: |
public | constant | Job is finished successfully. | |
Job:: |
public | function | Gets all stored exception data. | |
Job:: |
public | function | Gets the job id. | |
Job:: |
public | function | Gets all stored messages. | |
Job:: |
public | function | Gets the status of the job. | |
Job:: |
public | function | Gets the job tag. | |
Job:: |
public | constant | Job is waiting to be picked up by a worker. | |
Job:: |
public | function | Adds an exception to the exception storage. | |
Job:: |
public | function | Adds a message to the message storage. | |
Job:: |
public | constant | Job failed, waiting to be retried. | |
Job:: |
public | constant | Job is running. | |
Job:: |
public | constant | Job is claimed by a worker, but not running yet. | |
Job:: |
public | function | Sets the status of the job. | |
Job:: |
public | function | Sets the job tag. | |
Job:: |
public | function | Whether this job should be retried when an exception is thrown. | |
UserCreateUpdate:: |
protected | property | The Apigee Edge developer's email. | |
UserCreateUpdate:: |
protected | function | Execute actions after the user has been saved. | 1 |
UserCreateUpdate:: |
protected | function |
Executes the request itself. Overrides EdgeJob:: |
|
UserCreateUpdate:: |
protected | function |
Logs an entity conversation problems encountered meanwhile syncing. Overrides UserDeveloperSyncJobTrait:: |
|
UserCreateUpdate:: |
public | function |
UserCreateUpdate constructor. Overrides Job:: |
|
UserDeveloperSyncJobTrait:: |
protected | function | Field-attribute converter service. | |
UserDeveloperSyncJobTrait:: |
protected | function | Logs all entity conversion problems encountered meanwhile syncing. | |
UserDeveloperSyncJobTrait:: |
protected | function | Logger interface. | |
UserDeveloperSyncJobTrait:: |
protected | function | User-developer converter service. | |
UserUpdate:: |
protected | function |
Execute actions before the user gets saved. Overrides UserCreateUpdate:: |
|
UserUpdate:: |
public | function |
Returns this job's textual representation. Overrides Job:: |