function hook_party_data_set_info in Party 7
Same name and namespace in other branches
- 8.2 party.api.php \hook_party_data_set_info()
Defines data sets to be used by parties.
A data set is a collection of entities of one type (and optionally also one bundle) from which one or more entities may be attached to a party.
Return value
An array of sets where each key is the unique identifier of that "set type".
- 'label': The human readable name of the data set.
- 'entity type': The entity type this data set relates to parties.
- 'entity bundle': (optional) The entity bundle that this data set restricts to. May be omitted to allow any bundle.
- 'singleton': (optional) Whether this set's relationships only have one entity relating to a party. Default: FALSE.
- 'max cardinality': (optional) The maximum number of entities that may be attached within this data set. This is set to 1 if 'singleton' is TRUE.
- 'view mode': (optional) The name of one of the entity's view modes, to use for displaying entities attached to a party. If omitted, defaults to 'party', a view mode which is added to data set-enabled entities in party_entity_info_alter().
- 'form callback': (optional) This is the name of the form callback function. Returns the section of the form to do with this data set. See party_default_attached_entity_form().
- 'module': (optional) The name of the module implementing this data set. This will be filled in automatically if not supplied.
- 'admin': An array of admin paths for configuring and managing the piece:
- 'edit'
- 'manage fields'
- 'manage display'
- 'delete'
- 'create'
- 'import'
- 'clone'
- 'export'
- 'actions': An array defining actions that allow users to do things with the
attached entities within this data set. The keys of this array are the
action names, which are used as path components below the party and also
correspond to values of $op to party_access().
Each action array may contain the following properties:
- 'controller': The name of an action UI controller class. Party core
provides the following:
- PartyDefaultDataSetUIAdd: creates a new entity that is attached to the party.
- PartyDefaultDataSetUIAttach: attaches an existing entity to the party.
- 'action label': The text to use for the menu local action on the data
set piece. This should not be localized, as it is run through t() by
the system, with the following replacements:
- '@data-set': The data set label.
Note that the 'add' action is currently a special case which doesn't use the controller, though defining the action here determines access to it.
- 'controller': The name of an action UI controller class. Party core
provides the following:
- 'permissions': (optional) An array containing extra properties to pass to hook_permission() for each of the permissions party module provides for this data set. Each array may have a key for each of the actions party module provides a permission for ('view', 'attach', 'edit', 'detach'), and for any of these, the value should be an array of hook_permission() properties to set for the permission for this action on this data set.
- piece: (optional) Each set may define one party piece, which will be
returned by party_party_party_pieces(). The contents of this array should
be the same as those returned by hook_party_party_piece_info(), with the
addition of:
- 'maker': Defines the method for generating the piece. Can be one of:
- 'view': The display of this piece is handled by Views, via our default view in party_views_default_views().
- 'core': The piece is displayed using Party module's attached entity view page callback, party_view_data_set(). No keys other than this and the path are needed.
- 'callback': The module provides the callback to display the piece and defining it here rather than in hook_party_party_piece_info() is mostly just a convenience (though it does produce local action links too).
- 'path': The menu path component for the provided piece.
- 'view name': (optional) @todo! write the code for this! ;) The machine name of the view to define in hook_views_default_views(). This allows multiple default views to exist. Defaults to 'party_attached_entities'.
- 'maker': Defines the method for generating the piece. Can be one of:
2 functions implement hook_party_data_set_info()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- party_profile_party_data_set_info in modules/
party_profile/ party_profile.party_info.inc - Implements hook_party_data_set_info().
- party_user_party_data_set_info in modules/
party_user/ party_user.party_info.inc - Implements hook_party_data_set_info()
1 invocation of hook_party_data_set_info()
- party_get_data_set_info in ./
party.module - Get all data sets from hook_party_data_set_info().
File
- ./
party.api.php, line 132 - Hooks provided by the Party module.
Code
function hook_party_data_set_info() {
$sets = array();
// A user data set.
$sets['user'] = array(
'label' => t("User account"),
'entity type' => 'user',
'singleton' => TRUE,
// There is only one user per party.
'load callback' => "party_user_load_user",
'form callback' => "party_user_form_user",
);
return $sets;
}