function farm_constraint_exists in farmOS 7
Function for checking if a constraint exists (if a record is referenced by other records).
Parameters
$type: The entity type.
$bundle: The entity bundle.
$id: The entity id.
Return value
bool Returns TRUE if the record is referenced elsewhere, FALSE otherwise.
3 calls to farm_constraint_exists()
- farm_constraint_form_alter in modules/
farm/ farm_constraint/ farm_constraint.module - Implements hook_form_alter().
- farm_constraint_restws_request_alter in modules/
farm/ farm_constraint/ farm_constraint.module - Implements hook_restws_request_alter().
- farm_constraint_views_bulk_operations_form_validate in modules/
farm/ farm_constraint/ farm_constraint.module - Validation function for Views Bulk Operations form.
File
- modules/
farm/ farm_constraint/ farm_constraint.module, line 32 - Farm constraint module.
Code
function farm_constraint_exists($type, $bundle, $id) {
// Get a list of constraints.
$constraints = farm_constraint_list($type, $bundle, $id);
// Iterate through the constraints and return TRUE if any were detected.
foreach ($constraints as $constraint) {
if (!empty($constraint)) {
return TRUE;
}
}
// If we haven't already returned, no constraints were detected.
return FALSE;
}