1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
<?php
namespace SIW\Plato;
use Spatie\ArrayToXml\ArrayToXml;
class Export_Application extends Export{
protected $endpoint = 'ImportVolunteer';
protected $name = 'exporteren aanmelding';
protected function generate_xml() {
$this->xml_data = ArrayToXml::convert( $this->data, 'vef', true, 'UTF-8' );
}
protected function process_xml() {
$projectcode = $this->data['choice1'];
$success = (bool) $this->xml_response->Success;
if ( $success ) {
$imported_id = (string) $this->xml_response->ImportedIds->string;
$log_message = sprintf( 'Aanmelding voor %s succesvol geƫxporteerd naar PLATO als %s.', $projectcode, $imported_id );
$this->log( 'info', $log_message );
}
else {
$error_messages = $this->xml_response->ErrorMessages->string;
$note = sprintf( 'Export naar PLATO van aanmelding voor %s mislukt.', $projectcode );
$log_message = $note . wc_print_r( $error_messages );
$this->log( 'error', $log_message );
}
return [
'success' => $success,
'imported_id' => $imported_id ?? '',
'message' => $log_message,
];
}
}