class ServicesClientFieldD6Formatter in Services Client 7.2
D6 and D5 field formatter.
Hierarchy
- class \ServicesClientPlugin implements ServicesClientConfigurableInterface
- class \ServicesClientMapperPlugin implements ServicesClientMappingInterface
- class \ServicesClientFieldFormatter implements ServicesClientMappingFormatterInterface
- class \ServicesClientMapperPlugin implements ServicesClientMappingInterface
Expanded class hierarchy of ServicesClientFieldD6Formatter
5 string references to 'ServicesClientFieldD6Formatter'
- ServicesClientErrorWebTestCase::testServicesClientErrors in services_client_error/
tests/ services_client_error.test - ServicesClientHooksWebTestCase::testServicesClientHooks in tests/
services_client.test - ServicesClientWebTestCase::testServicesClientProcessing in tests/
services_client.test - services_client_migrate_add_mapping in ./
services_client.legacy.inc - Create mapping plugins by old configurration.
- services_client_services_client_mapping in ./
services_client.plugins.inc - List available mapping plugins.
File
- include/
mapping.inc, line 821
View source
class ServicesClientFieldD6Formatter extends ServicesClientFieldFormatter {
/**
* Get plugin configuration summary.
*
* @return string
* Configuration overview string.
*/
public function getSummary() {
if (empty($this->config['field'])) {
return '[FieldD6Formatter - not configured]';
}
else {
$multivalue = $this->config['multivalue'] == 'force_single' ? '0' : '*';
return "\$object-><b>{$this->config['field']}[{$multivalue}][{$this->config['property']}]</b>";
}
}
/**
* Retrieve empty value formatting by configuration.
*
* @return array|NULL
* Formatted empty value.
*/
protected function formatEmptyValue() {
if ($this->config['empty'] == 'no_field') {
return NULL;
}
elseif ($this->config['empty'] == 'null_field') {
return array(
'key' => $this->config['field'],
'value' => array(),
);
}
elseif ($this->config['empty'] == 'null_property') {
return array(
'key' => $this->config['field'],
'value' => NULL,
);
}
elseif ($this->config['empty'] == 'default_value') {
return array(
'key' => $this->config['field'],
'value' => array(
array(
$this->config['property'] => $this->config['default_value'],
),
),
);
}
}
/**
* Format source value array to field.
*
* @param array $values
* Source values that should be formatted.
*
* @return array
* Formatted value in format
*/
protected function formatArray($values) {
// Make handy shortcuts
$field = $this->config['field'];
$property = $this->config['property'];
// Build final value
$out = array();
foreach ($values as $value) {
$out[][$property] = $value;
}
// Return resulting value.
return array(
'key' => $this->config['field'],
'value' => $out,
);
}
/**
* Config form.
*/
public function configForm(&$form, &$form_state) {
parent::configForm($form, $form_state);
unset($form['formatter_config']['language']);
}
/**
* Submit config form.
*/
public function configFormSubmit(&$form, &$form_state) {
$this->config['field'] = $form_state['values']['formatter_config']['field'];
$this->config['property'] = $form_state['values']['formatter_config']['property'];
$this->config['multivalue'] = $form_state['values']['formatter_config']['multivalue'];
$this->config['empty'] = $form_state['values']['formatter_config']['empty'];
$this->config['default_value'] = $form_state['values']['formatter_config']['default_value'];
}
}