You are here

function hook_farm_constraint in farmOS 7

Defines farm constraint types.

Parameters

$type: The entity type.

$bundle: The entity bundle.

$id: The entity id.

Return value

array|bool This can either return an array of information about the constraint (see example below), or it can return a simple boolean TRUE/FALSE.

See also

farm_constraint_farm_constraint()

Related topics

3 functions implement hook_farm_constraint()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

farm_constraint_farm_constraint in modules/farm/farm_constraint/farm_constraint.farm_constraint.inc
Implements hook_farm_constraint().
farm_plan_consideration_farm_constraint in modules/farm/farm_plan/farm_plan_consideration/farm_plan_consideration.farm_constraint.inc
Implements hook_farm_constraint().
farm_plan_farm_constraint in modules/farm/farm_plan/farm_plan.farm_constraint.inc
Implements hook_farm_constraint().
1 invocation of hook_farm_constraint()
farm_constraint_list in modules/farm/farm_constraint/farm_constraint.module
Function for generating a list of constraints for a given entity.

File

modules/farm/farm_constraint/farm_constraint.api.php, line 40
Hooks provided by farm_constraint.

Code

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

  // Check to see if any other records reference this entity.
  // ...
  // Return information about the constraint. This should include a 'constraint'
  // key that is a unique constraint type. It can can include a simple
  // description message, information about entities that reference the entity,
  // and any other information you want to include. Each constraint should be an
  // array of information, so that multiple constraints can be included.
  return array(
    array(
      'constraint' => 'foo_constraint',
      'description' => t('You cannot delete this because I said so!'),
    ),
    array(
      'constraint' => 'bar_constraint',
      'entity_type' => 'log',
      'entity_id' => 1234,
    ),
  );
}