You are here

protected function DeveloperCreateUpdate::logConversionProblem in Apigee Edge 8

Logs an entity conversation problems encountered meanwhile syncing.

TODO Consider to add a translatable operation to message logged by recordMessage() if we actually start using that method something.

Parameters

\Drupal\apigee_edge\Exception\UserDeveloperConversionException $problem: Entity conversion problem.

array $context: Additional problem for log messages.

Overrides UserDeveloperSyncJobTrait::logConversionProblem

File

src/Job/DeveloperCreateUpdate.php, line 125

Class

DeveloperCreateUpdate
Base class for user create/update sync jobs.

Namespace

Drupal\apigee_edge\Job

Code

protected function logConversionProblem(UserDeveloperConversionException $problem, array $context = []) : void {
  $ro = new \ReflectionObject($this);
  $context = [
    '%mail' => $this->email,
    '@operation' => $ro
      ->getShortName(),
  ];
  if ($problem instanceof UserDeveloperConversionUserFieldDoesNotExistException) {
    $message = "@operation: %mail developer's %attribute_name attribute has been skipped because %field_name field does not exist.";
    $context['%field_name'] = $problem
      ->getFieldName();
    $context['%attribute_name'] = $this
      ->fieldAttributeConverter()
      ->getAttributeName($problem
      ->getFieldName());
    $this
      ->logger()
      ->warning($message, $context);
    $this
      ->recordMessage(t("%mail developer's %attribute_name attribute has been skipped because %field_name field does not exist.", $context)
      ->render());
  }
  elseif ($problem instanceof UserDeveloperConversionNoStorageFormatterFoundException) {
    $message = "@operation: %mail developer's %attribute_name attribute has been skipped because there is no available storage formatter for %field_type field type.";
    $context['%field_type'] = $problem
      ->getFieldDefinition()
      ->getType();
    $context['%attribute_name'] = $this
      ->fieldAttributeConverter()
      ->getAttributeName($problem
      ->getFieldDefinition()
      ->getName());
    $this
      ->logger()
      ->warning($message, $context);
    $this
      ->recordMessage(t("%mail developer's %attribute_name attribute has been skipped because there is no available storage formatter for %field_type field type.", $context)
      ->render());
  }
  else {
    $context += Error::decodeException($problem);
    $this
      ->logger()
      ->warning('@operation: Unexpected problem occurred while creating %mail user: @message %function (line %line of %file). <pre>@backtrace_string</pre>');
    $this
      ->recordMessage(t("Unexpected problem occurred while processing %mail developer: @message", $context)
      ->render());
  }
}