You are here

function farm_constraint_farm_constraint in farmOS 7

Implements hook_farm_constraint().

File

modules/farm/farm_constraint/farm_constraint.farm_constraint.inc, line 11
Farm constraint hook implementations.

Code

function farm_constraint_farm_constraint($type, $bundle, $id) {

  // Start an empty array of constraints.
  $constraints = array();

  // Check to see if there are any field references to this entity and add them
  // to the constraints.
  $references = farm_constraint_field_references($type, $id);
  if (!empty($references)) {
    $constraints += $references;
  }

  // If this is a taxonomy term, check to see if it has any children and add
  // them to the constraints.
  if ($type == 'taxonomy_term') {
    $children = farm_constraint_taxonomy_term_children($id);
    if (!empty($children)) {
      $constraints += $children;
    }
  }

  // Return constraints.
  return $constraints;
}