You are here

function entity_menu_links_create_revision in Entity menu links 7

Creates a new revision row, ready for insertion into the database.

1 call to entity_menu_links_create_revision()
entity_menu_links_insert_revision in ./entity_menu_links.module
Inserts a new revision for the given menu_link.

File

./entity_menu_links.module, line 173
Entity menu link module

Code

function entity_menu_links_create_revision($menu_link) {
  $fields = (array) $menu_link;
  $revisions = drupal_get_schema('menu_links_revision');
  $rev_fields = $revisions['fields'];
  foreach ($fields as $name => $value) {
    if (!isset($rev_fields[$name])) {
      unset($fields[$name]);
    }
    elseif (!is_scalar($fields[$name])) {
      $fields[$name] = serialize($value);
    }
  }
  unset($fields['vid']);
  $fields['timestamp'] = time();
  return $fields;
}