You are here

function flagging_create in Flag 7.3

Entity API creation callback.

Creates an unsaved flagging object for use with $flag->flag().

Parameters

array $values: An array of values as described by the entity's property info. Only 'flag_name' or 'fid' must be specified, since $flag->flag() does the rest.

Return value

An unsaved flagging object containing the property values.

1 string reference to 'flagging_create'
flag_entity_info in ./flag.module
Implements hook_entity_info().

File

./flag.module, line 93
The Flag module.

Code

function flagging_create($values = array()) {
  $flagging = (object) array();
  if (!isset($values['flag_name'])) {
    if (isset($values['fid'])) {

      // Add flag_name, determined from fid.
      $flag = flag_get_flag(NULL, $values['fid']);
      $values['flag_name'] = $flag->name;
    }
  }

  // Apply the given values.
  foreach ($values as $key => $value) {
    $flagging->{$key} = $value;
  }
  return $flagging;
}