You are here

function entity_rules_get_rule_options in Entity Rules 7

Gets Rules options for a select form element.

Parameters

$tag: Rule tag to filter on.

$entity_type:

Return value

Array of key value pairs.

1 call to entity_rules_get_rule_options()
entity_rules_new_bundle_rule_form in ./entity_rules.admin.inc
Form callback that should current rules for a bundle and operation.

File

./entity_rules.admin.inc, line 306
Admin functions.

Code

function entity_rules_get_rule_options($tag, $entity_type) {
  $conditions = array(
    //'plugin' => $plugin_types,
    'active' => TRUE,
  );
  $entities = entity_load('rules_config', FALSE, $conditions);
  ksort($entities);
  $rules = array();
  foreach ($entities as $entity) {
    if (in_array($tag, $entity->tags)) {
      $vars = $entity
        ->componentVariables();
      if (isset($vars['entity'])) {
        if ($vars['entity']['type'] == 'entity' || $vars['entity']['type'] == $entity_type) {
          $rules[$entity->name] = $entity->label;
        }
      }
    }
  }
  return $rules;
}