You are here

function commerce_condition_entity_exists_value_options_list in Commerce Core 7

Returns the options list specified for the chosen property.

1 string reference to 'commerce_condition_entity_exists_value_options_list'
commerce_condition_entity_exists_info_alter in ./commerce.rules.inc
Info alteration callback for the entity query action.

File

./commerce.rules.inc, line 107
Rules integration for Drupal Commerce.

Code

function commerce_condition_entity_exists_value_options_list(RulesAbstractPlugin $element) {

  // Get the possible values for the selected property.
  $element->settings += array(
    'type' => NULL,
    'property' => NULL,
  );
  if ($element->settings['type'] && $element->settings['property']) {
    $wrapper = entity_metadata_wrapper($element->settings['type']);
    if (isset($wrapper->{$element->settings['property']}) && ($property = $wrapper->{$element->settings['property']})) {
      return $property
        ->optionsList('view');
    }
  }
}