class ServicesClientPropertyReader in Services Client 7.2
Hierarchy
- class \ServicesClientPlugin implements ServicesClientConfigurableInterface
- class \ServicesClientMapperPlugin implements ServicesClientMappingInterface
- class \ServicesClientPropertyReader implements ServicesClientMappingReaderInterface
- class \ServicesClientMapperPlugin implements ServicesClientMappingInterface
Expanded class hierarchy of ServicesClientPropertyReader
7 string references to 'ServicesClientPropertyReader'
- ServicesClientErrorWebTestCase::testServicesClientErrors in services_client_error/
tests/ services_client_error.test - ServicesClientHooksWebTestCase::testServicesClientHooks in tests/
services_client.test - ServicesClientWebTestCase::testAddingEvent in tests/
services_client.test - Test basic event configuration actions.
- ServicesClientWebTestCase::testServicesClientProcessing in tests/
services_client.test - services_client_migrate_add_mapping in ./
services_client.legacy.inc - Create mapping plugins by old configurration.
File
- include/
mapping.inc, line 303
View source
class ServicesClientPropertyReader extends ServicesClientMapperPlugin implements ServicesClientMappingReaderInterface {
/**
* Retrieve default configuration.
*
* @return array
* Default configuration.
*/
protected function getDefaultConfiguration() {
return array(
'property' => '',
);
}
public function getSummary() {
if (empty($this->config['property'])) {
return '[PropertyReader - not configured]';
}
else {
return "\$source-><b>{$this->config['property']}</b>";
}
}
/**
* Read property data from entity.
*
* @param object $entity
* Drupal entity object.
*
* @return ServicesClientMappingValue
* Value definition.
*/
public function read($entity) {
$value = new ServicesClientMappingValue();
if (isset($entity->{$this->config['property']})) {
if (is_array($entity->{$this->config['property']})) {
$value
->setValue($entity->{$this->config['property']});
}
else {
$value
->setValue(array(
$entity->{$this->config['property']},
));
}
}
else {
$value
->setEmpty();
}
return $value;
}
public function configForm(&$form, &$form_state) {
$form['reader_config'] = array(
'#type' => 'fieldset',
'#title' => t('Property reader'),
'#tree' => TRUE,
);
$form['reader_config']['property'] = array(
'#type' => 'textfield',
'#title' => t('Property name'),
'#description' => t('Enter property name'),
'#default_value' => $this->config['property'],
);
}
public function configFormSubmit(&$form, &$form_state) {
$this->config['property'] = $form_state['values']['reader_config']['property'];
}
}