function entity_rules_load_settings_for_op in Entity Rules 7
Get Entity Rules Settings entities for entity type, bundle, op combo
Parameters
$entity_type:
$bundle:
$op:
bool $load_rules:
Return value
array
3 calls to entity_rules_load_settings_for_op()
- entity_rules_bundle_rules_form in ./
entity_rules.admin.inc - Form for setting Rule parmeters for a Bundle
- entity_rules_form_alter in ./
entity_rules.module - Implements hook_form_alter().
- _entity_rules_invoke_rules in ./
entity_rules.module - Invokes Rules for an entity given an operation.
File
- ./
entity_rules.module, line 1079 - Module file for the Entity Rules.
Code
function entity_rules_load_settings_for_op($entity_type, $bundle, $op, $load_rules = FALSE) {
$enabled_types = variable_get('entity_rules_types', explode(',', ENTITY_RULES_DEFAULT_TYPES));
if (array_search($entity_type, $enabled_types, TRUE) === FALSE) {
return array();
}
$conditions = array(
'entity_type' => $entity_type,
'bundle' => $bundle,
'op' => $op,
);
$entities = entity_load('entity_rule_setting', FALSE, $conditions);
if ($load_rules) {
foreach (array_keys($entities) as $entity_id) {
$entities[$entity_id]->loaded_rules_config = rules_config_load($entities[$entity_id]->rules_config);
// If rule didn't load unset this entity
if (empty($entities[$entity_id]->loaded_rules_config)) {
unset($entities[$entity_id]);
}
}
}
return $entities;
}