Created
October 17, 2014 14:07
-
-
Save labboy0276/9c122fa2dd4447c67edc to your computer and use it in GitHub Desktop.
cvt field collection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _cvt_client_trigger_field_collection_modification($entity, $type){ | |
//If this isn't a field_collection submitted through a form, | |
//and ready to trigger Rules, we don't want it. | |
$entity_types = array( | |
'field_dependent' => 'dependent', | |
'field_plans' => 'plans', | |
'field_enrollee' => 'enrollee', | |
'field_dependent_cancellation' => 'dependent_cancellation', | |
); | |
$test = '1'; | |
if ($type == 'field_collection_item' && isset($entity->form_id) | |
&& module_exists('rules') && array_key_exists($entity->field_name, $entity_types) | |
&& !isset($entity->rules_seconds)) { | |
$entity_type = $entity_types[$entity->field_name]; | |
$entity->rules_seconds = TRUE; | |
//Trigger rule events | |
if (isset($entity->original)){ | |
$entity_original = $entity->original; | |
rules_invoke_event('cvt_client_' . $entity_type . '_updated', $entity, $entity_unchanged); | |
} | |
elseif ($entity_type == 'dependent' || $entity_type == 'dependent_cancellation'){ | |
rules_invoke_event('cvt_client_'. $entity_type . '_created', $entity); | |
} | |
} | |
elseif ($type == 'field_collection_item' && module_exists('rules') | |
&& array_key_exists($entity->field_name, $entity_types) | |
&& !isset($entity->rules_seconds) && $entity->field_name != 'field_enrollee') { | |
$entity_type = $entity_types[$entity->field_name]; | |
$entity->rules_seconds = TRUE; | |
//Trigger rule events | |
if ($entity_type == 'dependent' || $entity_type == 'dependent_cancellation'){ | |
rules_invoke_event('cvt_client_'. $entity_type . '_created', $entity); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment