function cer_processing_entity in Corresponding Entity References 7
Same name and namespace in other branches
- 7.3 cer.module \cer_processing_entity()
- 7.2 cer.module \cer_processing_entity()
Process a entity's corresponding entity references.
Parameters
$op the operation being performed on the entity.:
$entity the entity object:
$process_unchanged whether or not to process entity reference fields: whose values have not changed.
4 calls to cer_processing_entity()
- cer_batch_update_existing_entities in ./
cer.module - Batch Operation Callback
- cer_entity_delete in ./
cer.module - Implements hook_entity_delete().
- cer_entity_insert in ./
cer.module - Implements hook_entity_insert().
- cer_entity_update in ./
cer.module - Implements hook_entity_update().
File
- ./
cer.module, line 125 - Module file providing the "corresponding entity reference" module main functions.
Code
function cer_processing_entity($op, $entity, $type, $process_unchanged = FALSE) {
module_load_include('inc', 'cer', 'cer.crud');
$result = cer_preset_load_enabled();
while ($row = array_shift($result)) {
$key = explode('*', $row->entity_types_content_fields);
if ($type == $key[0] || $type == $key[3]) {
$entity->home = _cer_entity_get_bundle($entity, $type);
switch ($entity->home) {
case $key[1]:
// Create an array to pass to op function instead of 6 arguments.
$keys = array(
'home_entity_type' => $key[0],
'home_bundle' => $key[1],
'home_field' => $key[2],
'away_entity_type' => $key[3],
'away_bundle' => $key[4],
'away_field' => $key[5],
);
$args = array(
$entity,
$keys,
$process_unchanged,
);
$function = 'cer_' . $op;
call_user_func_array($function, $args);
// Only continue on to check the reverse direction of this preset if
// the home & away bundles & entity types are the same.
if ($key[0] != $key[3] || $key[1] != $key[4]) {
break;
}
// Fall through.
case $key[4]:
$keys = array(
'home_entity_type' => $key[3],
'home_bundle' => $key[4],
'home_field' => $key[5],
'away_entity_type' => $key[0],
'away_bundle' => $key[1],
'away_field' => $key[2],
);
$args = array(
$entity,
$keys,
$process_unchanged,
);
$function = 'cer_' . $op;
call_user_func_array($function, $args);
break;
}
}
}
}