You are here

function hook_farm_plan_record_relationships in farmOS 7

Define farm plan record relationships.

This will be used to automatically integrate with Views, and create constraints on linked records.

Return value

array Returns an array of record types with the database table and field names used to store relationships, using the following keys:

  • label: The human-readable label for this record type.
  • entity_type: The Drupal entity type.
  • entity_pk: The column name of the entity type's primary key.
  • table: The table that links the record to the plan.
  • field: The column name in the table that links to the record's PK.
  • required: It's possible for one table to maintain multiple relationships so this key indicates that this relationship is required. This defaults to TRUE, so generally you only need to set it to FALSE if you are adding an optional relationship to an existing table. This affects how the farm_plan_link_record() and farm_plan_link_record() functions work, and whether they will insert/delete rows or update them instead.

Related topics

1 function implements hook_farm_plan_record_relationships()

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

farm_plan_farm_plan_record_relationships in modules/farm/farm_plan/farm_plan.module
Implements hook_farm_plan_record_relationships().
1 invocation of hook_farm_plan_record_relationships()
farm_plan_record_relationships in modules/farm/farm_plan/farm_plan.module
Defines available relationships between plans and other record types.

File

modules/farm/farm_plan/farm_plan.api.php, line 46
Hooks provided by farm_plan.

Code

function hook_farm_plan_record_relationships() {
  return array(
    'my_plan_asset' => array(
      'label' => t('Asset'),
      'entity_type' => 'farm_asset',
      'entity_pk' => 'id',
      'table' => 'my_plan_asset',
      'field' => 'asset_id',
    ),
    'my_plan_log' => array(
      'label' => t('Log'),
      'entity_type' => 'log',
      'entity_pk' => 'id',
      'table' => 'my_plan_asset',
      'field' => 'log_id',
      'required' => FALSE,
    ),
  );
}