You are here

class ServicesClientPropertyReader in Services Client 7.2

Hierarchy

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.

... See full list

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'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ServicesClientMapperPlugin::configFormValidate public function Validate configuration form. Overrides ServicesClientPlugin::configFormValidate
ServicesClientMapperPlugin::__construct public function Constructor. Overrides ServicesClientPlugin::__construct
ServicesClientPlugin::$config protected property Plugin specific configuration
ServicesClientPlugin::$event protected property Event definition
ServicesClientPlugin::getConfiguration public function Retrieve current plugin configuration. Overrides ServicesClientConfigurableInterface::getConfiguration
ServicesClientPlugin::setConfiguration public function Set configuration of plugin. Overrides ServicesClientConfigurableInterface::setConfiguration
ServicesClientPropertyReader::configForm public function Configuration form options Overrides ServicesClientMapperPlugin::configForm
ServicesClientPropertyReader::configFormSubmit public function Submit configuration form and save config. Overrides ServicesClientMapperPlugin::configFormSubmit
ServicesClientPropertyReader::getDefaultConfiguration protected function Retrieve default configuration. Overrides ServicesClientMapperPlugin::getDefaultConfiguration
ServicesClientPropertyReader::getSummary public function Retrieve condition summary for UI. Overrides ServicesClientMappingInterface::getSummary
ServicesClientPropertyReader::read public function Read property data from entity. Overrides ServicesClientMappingReaderInterface::read