toSoapArray(); $time_submitted = time(); $relais_message = is_array($response) ? (isset($response['ConfirmMessage']) ? $response['ConfirmMessage'] : ($response['Problem']['Message'] ?? '')) : (string) $response; $patron_firstname = ''; $patron_lastname = ''; if (!empty($soap_data['PatronName'])) { $parts = explode(' ', $soap_data['PatronName'], 2); $patron_firstname = trim($parts[0] ?? ''); $patron_lastname = trim($parts[1] ?? ''); } $connection = \Drupal::service('database'); try { $connection->insert('upei_roblib_ill_request') ->fields([ 'patron_id' => $soap_data['PatronId'] ?? '', 'patron_firstname' => $patron_firstname, 'patron_lastname' => $patron_lastname, 'patron_type' => '', 'patron_department' => $soap_data['PatronDepartment'] ?? '', 'patron_email' => $soap_data['PatronEmail'] ?? '', 'notes' => $soap_data['PatronNotes'] ?? '', 'genre' => $soap_data['RapidRequestType'] ?? '', 'doi' => '', 'author' => $soap_data['ArticleAuthor'] ?? '', 'citation_date' => $soap_data['PatronJournalYear'] ?? '', 'title' => $soap_data['PatronJournalTitle'] ?? '', 'atitle' => $soap_data['ArticleTitle'] ?? '', 'issn' => $soap_data['SuggestedIssns']['string'][0] ?? '', 'isbn' => $soap_data['SuggestedIsbns']['string'][0] ?? '', 'article_author' => $soap_data['ArticleAuthor'] ?? '', 'volume' => $soap_data['JournalVol'] ?? '', 'issue' => $soap_data['JournalIssue'] ?? '', 'pages_requested' => $soap_data['ArticlePages'] ?? '', 'time_submitted' => $time_submitted, 'relais_request_id' => is_array($response) && isset($response['RequestNumber']) ? $response['RequestNumber'] : '-1', 'relais_message' => substr($relais_message, 0, 254), ])->execute(); } catch (Exception $e) { \Drupal::logger('upei_roblib_ill')->error('Error logging ILL request @msg', array( '@msg' => $e->getMessage(), )); } }