class WsclientRestXMLFormatter in Web service client 7
Hierarchy
- class \HttpClientXMLFormatter implements HttpClientFormatter
- class \WsclientRestXMLFormatter
Expanded class hierarchy of WsclientRestXMLFormatter
2 string references to 'WsclientRestXMLFormatter'
- WsclientRestXMLFormatter::formAlter in wsclient_rest/
wsclient_rest.inc - WsclientRestXMLFormatter::formSubmit in wsclient_rest/
wsclient_rest.inc
File
- wsclient_rest/
wsclient_rest.inc, line 264 - Web service client REST - include file.
View source
class WsclientRestXMLFormatter extends HttpClientXMLFormatter {
public function __construct($settings = array()) {
parent::__construct(!empty($settings['default_root']) ? $settings['default_root'] : NULL, !empty($settings['adaptive_root']) ? $settings['adaptive_root'] : NULL);
$this->settings = $settings;
}
public function formAlter(&$form, &$form_state) {
switch ($form_state['form']) {
case 'main':
$service = $form_state['service'];
$info = module_invoke_all('wsclient_rest_formatter_info');
$default_formatter_settings = $info['WsclientRestXMLFormatter']['settings'];
foreach (array(
'send_formatter',
'receive_formatter',
) as $formatter_type) {
// Alias for such long nested path.
$formatter_settings = !empty($service->settings[$formatter_type]['settings']) ? $service->settings[$formatter_type]['settings'] : array();
// UI for settings.
$form['settings'][$formatter_type]['settings']['default_root'] = array(
'#type' => 'textfield',
'#title' => t('Default root'),
'#default_value' => isset($formatter_settings['default_root']) ? $formatter_settings['default_root'] : $default_formatter_settings['default_root'],
'#description' => t('Default root for created XML documents.'),
'#states' => array(
'visible' => array(
'select[name="settings[' . $formatter_type . '][class]"]' => array(
'value' => 'WsclientRestXMLFormatter',
),
),
),
);
$form['settings'][$formatter_type]['settings']['adaptive_root'] = array(
'#type' => 'checkbox',
'#title' => t('Adaptive root'),
'#default_value' => isset($formatter_settings['adaptive_root']) ? $formatter_settings['adaptive_root'] : $default_formatter_settings['adaptive_root'],
'#description' => t('If it is set to TRUE and the source data has a single root attribute the formatter will use that attribute as root. The object %foo_object would be serialized to %foo_wrapped instead of %foo_wrapped_result.', array(
'%foo_object' => '{"foo":"bar"}',
'%foo_wrapped' => '<foo>bar</foo>',
'%foo_wrapped_result' => '<result><foo>bar</foo></result>',
)),
'#states' => array(
'visible' => array(
'select[name="settings[' . $formatter_type . '][class]"]' => array(
'value' => 'WsclientRestXMLFormatter',
),
),
),
);
}
break;
}
}
public function formSubmit($form, &$form_state) {
switch ($form_state['form']) {
case 'main':
// Remove XML settings from the formatters that are not XML.
foreach (array(
'send_formatter',
'receive_formatter',
) as $formatter_type) {
if (empty($form_state['values']['settings'][$formatter_type]['formatter'])) {
continue;
}
if ($form_state['values']['settings'][$formatter_type]['formatter'] != 'WsclientRestXMLFormatter') {
foreach (array(
'default_root',
'adaptive_root',
) as $setting) {
unset($form_state['values']['settings'][$formatter_type]['settings'][$setting]);
}
}
}
break;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HttpClientXMLFormatter:: |
private | property | ||
HttpClientXMLFormatter:: |
private | property | ||
HttpClientXMLFormatter:: |
public | function |
Return the mime type that the formatter can parse. Overrides HttpClientFormatter:: |
|
HttpClientXMLFormatter:: |
public | function |
Return the content type form the data the formatter generates. Overrides HttpClientFormatter:: |
|
HttpClientXMLFormatter:: |
public | function | ||
HttpClientXMLFormatter:: |
private | function | Sanitizes a string so that it's suitable for use as a element or attribute name. | |
HttpClientXMLFormatter:: |
public | function |
Serializes arbitrary data to the implemented format.
Directly stolen from http_server by Hugo Wetterberg Overrides HttpClientFormatter:: |
|
HttpClientXMLFormatter:: |
public | function |
Unserializes data in the implemented format. Overrides HttpClientFormatter:: |
|
HttpClientXMLFormatter:: |
protected | function | Directly stolen from http_server by Hugo Wetterberg | |
WsclientRestXMLFormatter:: |
public | function | ||
WsclientRestXMLFormatter:: |
public | function | ||
WsclientRestXMLFormatter:: |
public | function |
Creates a HttpClientXMLFormatter. Overrides HttpClientXMLFormatter:: |